Expand my Community achievements bar.

SOLVED

Update Folder properties & access rights using DB script

Avatar

Level 3

Hi All,

 

I am creating folder structure using DB script for new brands so that when new brand/product is launched admin will run the script so the default hierarchy will be created. I want to update the folder properties such as folder image icon, access rights with script, please let me know how can I achieve this?

 

parmeshwarr3905_0-1661789665636.png

 

parmeshwarr3905_1-1661789701782.png

 

following similar kind of approach available on below post to create folder structure:

https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/adobe-campaign-cla... 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @parmeshwarr3905 

 

Try with this code.

 

xtk.session.Write(<rights _operation="insert" xtkschema="xtk:rights" operator-id={operatorId} folder-id={folderId} rights="write" />


     Manoj
     Find me on LinkedIn

View solution in original post

6 Replies

Avatar

Community Advisor

Hello @parmeshwarr3905 

 

You can use the same code from the link you have shared and add an additional attributes (highlighted below) for an image like this:


var admin = NLWS.xtkFolder.create({x:{model: 'xtkFolder', label: 'Administration','image-name':'deliveryModel.png','image-namespace':'cus', name: prefix+'Administration', 'parent-id': root.id}});

 

Also, make sure the image is available under Administration >  Configuration >  Images

 

Now you have the folder read and should also have the primary folder key. It is time to assign the permissions to this folder by writing another javascript function like this.

xtk.session.Write(<rights _operation="insert" operator-id="PRIMARY_KEY_OF_GROUP_OR_OPERATOR" folder-id="FOLDER_PRIMARY_KEY" rights="read|write" />);


 

 


     Manoj
     Find me on LinkedIn

Avatar

Level 3

@_Manoj_Kumar_  I am able to update image as I had missed namespace attribute previously. Now it's working fine.

 

but for access rights, it's throwing an error:

 

JST-310000 Error while compiling script 'WKF5322/js5' line 12: invalid XML attribute value (line='xtk.session.Write(<rights _operation="insert" operator-id=7577116262 folder-id=16113886126 rights="write" />); ' token='7577116262 folder-id=16113886126 rights="write" />); ').

 

I have copied the function as it is and updated it with primary keys.
 pls let me know what exactly could be be the issue and how can I resolve this.

 

Thanks

Avatar

Community Advisor

@parmeshwarr3905 

 

Try this.

 

var operatorId=7577116262;

var folderId=16113886126;

xtk.session.Write(<rights _operation="insert" operator-id={operatorId} folder-id={folderId} rights="write" />


     Manoj
     Find me on LinkedIn

Avatar

Level 3

Hi @_Manoj_Kumar_ 

 

It is throwing below error hence I have added - xtkschema="xtk:folder"

 

 js5 XSV-350026 The entity schema is not specified starting from attribute 'xtkschema'

 js5 SOP-330011 Error while executing the method 'Write' of service 'xtk:persist|xtk:session'.

 

It has run without error but I don't see any change in the access rights.

Avatar

Correct answer by
Community Advisor

Hello @parmeshwarr3905 

 

Try with this code.

 

xtk.session.Write(<rights _operation="insert" xtkschema="xtk:rights" operator-id={operatorId} folder-id={folderId} rights="write" />


     Manoj
     Find me on LinkedIn

Avatar

Level 3

Thank you so much @_Manoj_Kumar_ it's working, but aren't we supposed to provide folder as schema since we are modifying it's properties? Also I don't see any  'xtk:rights' in data schemas only nms:rights is available.