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:
Solved! Go to Solution.
Views
Replies
Total Likes
Hello @parmeshwarr3905
Try with this code.
xtk.session.Write(<rights _operation="insert" xtkschema="xtk:rights" operator-id={operatorId} folder-id={folderId} rights="write" />
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" />);
Views
Replies
Total Likes
@_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
Views
Replies
Total Likes
Try this.
var operatorId=7577116262;
var folderId=16113886126;
xtk.session.Write(<rights _operation="insert" operator-id={operatorId} folder-id={folderId} rights="write" />
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Hello @parmeshwarr3905
Try with this code.
xtk.session.Write(<rights _operation="insert" xtkschema="xtk:rights" operator-id={operatorId} folder-id={folderId} rights="write" />
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.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies