Need help with rule (script) to set document as read only

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Need help with rule (script) to set document as read only

Jump to solution

I have a document that goes through various reviews and then when the final review is approved I want to set the permisions of the document to read-only. I have the rule calling my javascript code and it works for administrators but does not work for normal (non-admin) users. Normal users when the rule runs I see this error in the log: 

Access Denied. You do not have the appropriate permissions to perform this operation.

 

Is there a way for a nomal user to be able to set the permissions of the document to read-only

or in the script give them elevated privlidges temporarlity to set the permisions.

 

This is my code fragment:

    //
    // Set the Permission we want    
    //      Alfrseco Admins Delete
    //       Everyone Read-Only
    //
    document.setPermission("Delete""GROUP_ALFRESCO_ADMINISTRATORS");
 
    document.setPermission("Read""GROUP_EVERYONE");

    //
    // Stop inherting permissions
    //
    document.setInheritsPermissions(false);

 

Thank You

 

1 Solution

Accepted Solutions
Highlighted

Re: Need help with rule (script) to set document as read only

Jump to solution

It's tricky, but you can do something similar to:

https://angelborroy.wordpress.com/2015/07/24/alfresco-run-as-system-admin-user-without-credentials/

>> From JavaScript (server side)

Software Engineer in Alfresco Search Team.

View solution in original post

4 Replies
Highlighted

Re: Need help with rule (script) to set document as read only

Jump to solution

It's tricky, but you can do something similar to:

https://angelborroy.wordpress.com/2015/07/24/alfresco-run-as-system-admin-user-without-credentials/

>> From JavaScript (server side)

Software Engineer in Alfresco Search Team.

View solution in original post

Highlighted
Active Member

Re: Need help with rule (script) to set document as read only

Jump to solution

Thank you I saw that article and the one that it referred to also.

The code looks straight foward.

What I didn't see what where to put the Java file and where to put the XML files.

 

From https://docs.alfresco.com/4.1/tasks/ext-file-config.html

I think I know where the XML file would go. 

Still looking for where the Java file would go.

Highlighted
Active Member

Re: Need help with rule (script) to set document as read only

Jump to solution

I think I found where the XML file would go from this page

https://docs.alfresco.com/4.1/tasks/ext-file-config.html

Still looking for where the Java code would go.

Highlighted
Senior Member II

Re: Need help with rule (script) to set document as read only

Jump to solution

You have to use customization for that.

Please use sdk for customization.

Thanks & Regard,
Sanjay