Make field Read Only in the change form after the Approval User Workflow activity...

Aravind3
Tera Contributor

Hi Folks,

I have a requirement like ,,,I do not want to have the impacted user list
to be updated after Change has gone through CAB approval.

In the workflow there is an workflow Activity called "CAB Approval" it requests approval from the CAB group..After approval I want to make the field "Read only"

Field Name: "impacted_user"

I tried with onDisplay BR and OnLoad Client script..

 

Business Rule:

function CABReview() {

       //Query sys_approval table
    var gr=new GlideRecord ('sysapproval_approver');
        gr.addQuery('wf_activity','=','CAB Review');
        gr.addQuery('state','=','Approved');
        gr.addQuery();
       //return true if 2nd round approval
    if("wf_activity','=','CAB Review" && "'state','=','Approved'")
        
        return(true);

}

g_scratchpad.CAB_Review = CABReview();

 

Client Script:

function onLoad() {
   //Type appropriate comment here, and begin script below
   if ( g_scratchpad.CAB_Review == true) {
        g_form.setReadOnly(u_affected_accounts, true);    
}
}

Please help me!!!!

4 REPLIES 4

Naveen4
Kilo Guru

function CABReview() {

       //Query sys_approval table
    var gr=new GlideRecord ('sysapproval_approver');
        gr.addQuery('wf_activity','=','CAB Review');
        gr.addQuery('state','=','Approved');
        gr.addQuery();//  repalce here with gr.query();
       //return true if 2nd round approval
    if("wf_activity','=','CAB Review" && "'state','=','Approved'")
        
        return(true); // return true ;

}

go through this.

https://community.servicenow.com/community?id=community_question&sys_id=9fa5cfeddbd8dbc01dcaf3231f961906

Coleton
Kilo Guru

Try that script instead of the current BR you have.

 function CABReview() {
    //Query sys_approval table
    var gr = new GlideRecord('sysapproval_approver');
    gr.addQuery('wf_activity', 'CAB Review');
    gr.addQuery('state', 'Approved');
    gr.query(); // Look for the records that match the above criteria

    if (gr.next()) { // If we find one, return true
        return (true);
    }
}

g_scratchpad.CAB_Review = CABReview();

Aravind3
Tera Contributor

Still I can able to edit the edit the field..

 

Is there any other way to achieve this..

In your onLoad script, see if you're even receiving a value for your scratchpad value.

e.g. gs.addInfoMessage('CAB Review value is: ' + g_scratchpad.CAB_review');

Also, you might want to make the comparison of:

//Client Script:

function onLoad() {
    if ( g_scratchpad.CAB_Review == 'true') { // Add quotes to true on this check.
         g_form.setReadOnly('u_affected_accounts', true); // Variable name should have quotes around it as well.
    }
}

If this resolves your problem, please mark this as correct.