vasanth
I'm new here

Unable to change the state of "Define Permission" in CMS_INPUT_PERMISSION

Jump to solution

Hello All,

I have CMS_INPUT_PERMISSION element in the metadata and the i have few roles are there. Now I want to uncheck the Check box of "Define Permission" (Which is highlighted in the below image). I tried it through the bean shell but i couldn't able to that.

CMS_INPUT_PERMISSION_DOCU_COLUMN.png

Please find my code for uncheck the "Define Permission " below

context.getStoreElemet ().getMetaFormData ().get (context.getProject ().getMasterLanguage (),"portal_roles").get ().setInherited (false);

But the above didn't uncheck the "Define Permission" check box.

Please let me know if there is any other way to change the state of the "Define Permission" check box.

Thank you,

Vasandharaj.

1 Solution

Accepted Solutions
marro
Crownpeak employee

Hello Vasandharaj,

first of all you have to lock the StoreElement you want to edit:

elem = context.getStoreElement();

elem.setLock(true);

Then you have to retrieve the FormData, apply your changes and set the FormData back to the StoreElement. You want to set inherited to true to uncheck the checkbox.

formdata = elem.getMetaFormData();

roles = formdata.get(context.getProject().getMasterLanguage (),"portal_roles").get();

roles.setInherited(true);

elem.setMetaFormData(formdata);

The last step is to save and unlock the StoreElement:

elem.save();

elem.setLock(false);

After refreshing the element in the GUI you will see your changes.

Regards,

Donato

View solution in original post

8 Replies
marro
Crownpeak employee

Hello Vasandharaj,

first of all you have to lock the StoreElement you want to edit:

elem = context.getStoreElement();

elem.setLock(true);

Then you have to retrieve the FormData, apply your changes and set the FormData back to the StoreElement. You want to set inherited to true to uncheck the checkbox.

formdata = elem.getMetaFormData();

roles = formdata.get(context.getProject().getMasterLanguage (),"portal_roles").get();

roles.setInherited(true);

elem.setMetaFormData(formdata);

The last step is to save and unlock the StoreElement:

elem.save();

elem.setLock(false);

After refreshing the element in the GUI you will see your changes.

Regards,

Donato

Hello Donato,

Thank your code snippet. I did everything except the elem.setMetaFormData(formdata). Now its working.

Thank you for your Help !!!!

0 Kudos

Hello Donato,

After releasing the lock I plan do the refresh the element through API. But I tried the few method in the API, it doesn't help me.

elem.refresh ();

elem.refresh (true);

elem.refresh (true, false);

elem.refreshWithReferences ();

But nothing seems to be working ..

Any other way to implement the refresh the element through API ???

Thank you in advance.

Regards,

Vasandharaj,

0 Kudos
marro
Crownpeak employee

Hello Vasandharaj,

can you tell me which version of FirstSpirit you are using?

And what exactly would you like to do? Can you explain your scenario to me?

Regards,

Donato

0 Kudos

Hello Donato,

FS Server Version: 4.2.476.52922.

I need to "reject the defined rights" (CMS_INPUT_PERMISSION) of the each and every Page reference in the site store through the API

 

  metaFormData = pageRefElement.getMetaFormData ();

  roles = metaFormData.get (masterLang, "portal_roles").get ();

  pageRefElement.setLock(true);

                              roles.setInherited(true);

                              pageRefElement.setMetaFormData(metaFormData);

                              pageRefElement.save ();

                              pageRefElement.release (false);

                              pageRefElement.setLock(false);

                              element.refresh ();

but the last line (page refresh is not working as intended)

Thank You,

Vasandharaj.

0 Kudos
marro
Crownpeak employee

Hello Vasandharaj,

Why do you want to refresh the element?

The refresh() method on an element loads the last saved version of this element from the server. But since you just edited the element and then saved it, the client already has the last saved version of this element. Calling this refresh() method only updates the data in your client with the data from the server. It does not refresh the GUI, if it's this what you would like to do.

Regards,

Donato

0 Kudos

Hello Donato,

Thank you for your explanation. Is way to refresh the GUI through the API ??

Regards,

vasandharaj

0 Kudos
marro
Crownpeak employee

Hello Vasandharaj,

unfortunately there is now way to refresh the GUI through the API.

Regards

Donato

0 Kudos