خرید بک لینک

Vote count: 0

I'm using Google Apps Script, whose Drive library has the following function:

setSharing(accessType, permissionType)
    accessType: Access (enum)
    permissionType: Permission (enum)

To allow for a good user experience, I have the following objects to match enum values to nice Strings, and vice-verca (I only show here the objects for the Access, but I have the same for the Permission):

/*** Method 1 ***/
var ACCESS_STR = {};
var ACCESS_ID = {};
ACCESS_STR[ DriveApp.Access.ANYONE ]           = "Any.";
ACCESS_STR[ DriveApp.Access.ANYONE_WITH_LINK ] = "Any. w/link";
ACCESS_STR[ DriveApp.Access.DOMAIN ]           = "Domain";
...
ACCESS_ID[ "Any." ] = DriveApp.Access.ANYONE;
ACCESS_ID[ "Any. w/link" ] = DriveApp.Access.ANYONE_WITH_LINK;
ACCESS_ID[ "Domain" ] = DriveApp.Access.DOMAIN;
...

What i'd like to do is to programmatically build the second object since all the needed information is already contained in the first one; this is what I do: /* Method 1 */ var ACCESS_STR = {}; var ACCESS_ID = {}; ACCESS_STR[ DriveApp.Access.ANYONE ] = "Any."; ACCESS_STR[ DriveApp.Access.ANYONE_WITH_LINK ] = "Any. w/link"; ACCESS_STR[ DriveApp.Access.DOMAIN ] = "Domain"; ... for( var a in ACCESS_STR ) { ACCESS_ID[ ACCESS_STR[a] ] = a; }

Now, if I call setSharing( ACCESS_ID["Any."], PERMISSION_ID["Edit"]), then

  • with method 1, it works
  • with method 2, I get a setSharing(string,string) method unknown error.

Why is that, and how can I cast back the strings to the enum type?

asked 39 secs ago

برچسب: how to uncast a horse,how to uncast a love spell,how to uncast a spell,how to uncast a circle,how to cast chromecast,how to uncast knitting,how to uncast glamour,how to unlock shadows uncast,how to attack a castled king, نویسنده: استخدام کار تاريخ: سه شنبه 9 شهريور 1395 ساعت: 16:47

صفحه بندی