Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

write access acl to the field based on sys_user refrence field

abhijeet khale
Tera Contributor

I have to configure write ACL to specific field on the Stockroom Table. This "write" permission should be assined to the "Stockroom Manager (sys_user)"  field. 

 @Ankur Bawiskar  @Community Alums could you please suggest.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @abhijeet khale ,

You can write business rule for the same. 

If logges_in user == Stockroom Manager , then only it will allow to save any changes.

 

Or You can apply the same logic in ACL script section, something like this.

// Get the current stockroom record
var gr = new GlideRecord('alm_stockroom');
if (gr.get(current.sys_id)) {
    // Check if the current user is the stockroom manager
    if (gr.manager == gs.getUserID()) {
        // Allow access
        answer = true;
    } else {
        // Deny access
        answer = false;
    }
} else {
    // Deny access if record is not found
    answer = false;
}

 

Thanks.

Hope it helps.

Mark it helpful and accept solution if my response turns useful.

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Hi @abhijeet khale ,

You can write business rule for the same. 

If logges_in user == Stockroom Manager , then only it will allow to save any changes.

 

Or You can apply the same logic in ACL script section, something like this.

// Get the current stockroom record
var gr = new GlideRecord('alm_stockroom');
if (gr.get(current.sys_id)) {
    // Check if the current user is the stockroom manager
    if (gr.manager == gs.getUserID()) {
        // Allow access
        answer = true;
    } else {
        // Deny access
        answer = false;
    }
} else {
    // Deny access if record is not found
    answer = false;
}

 

Thanks.

Hope it helps.

Mark it helpful and accept solution if my response turns useful.

Ankur Bawiskar
Tera Patron
Tera Patron

@abhijeet khale 

so please share what did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you for quick response Ankur. My query has been resolved.