Update Folder properties & access rights using DB script | Community
Skip to main content
Level 3
August 29, 2022
Solved

Update Folder properties & access rights using DB script

  • August 29, 2022
  • 1 reply
  • 1478 views

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?

 

 

 

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

https://experienceleaguecommunities.adobe.com/t5/adobe-campaign-classic-questions/adobe-campaign-classic-folder-structure-creation-using-database/m-p/308462#M8577 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by _Manoj_Kumar_

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.


Hello @parmeshwarr3905 

 

Try with this code.

 

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

1 reply

_Manoj_Kumar_
Community Advisor
Community Advisor
September 1, 2022

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
Level 3
September 1, 2022

@_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

_Manoj_Kumar_
Community Advisor
Community Advisor
September 1, 2022

@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