need help in script v2

nameisnani
Mega Sage

Hi Team , 

 

can anyone please help me with this issue 

 

In RITM form i have configured custom fields 

nameisnani_0-1733881380399.png

 

 

I have wirtten business rule and cilent script for this 

nameisnani_1-1733881380446.png

 

nameisnani_2-1733881380441.png

 

 

cilent script 

nameisnani_3-1733881380449.png

 

function onLoad() {
    //Type appropriate comment here, and begin script below

    var b = g_scratchpad.ritmvisble; //Value from BR -Checking if user is part of tech hub or Operations team- if logged user is member of either AVN-TechHub-SUP / CFS_ITOperations_OPS_APR or not.


    if (b) {


        // 		g_form.setDisplay('u_escalation', true);
        // 		g_form.setDisplay('u_escalation_comments', true);


        g_form.setReadOnly('u_escalation', false);
        g_form.setReadOnly('u_escalation_comments', false);
        g_form.setReadOnly('u_esc_by_ritm', false);
        g_form.setReadOnly('u_esc_date_time_ritm', false);
    } else {


        g_form.setReadOnly('u_escalation', false);
        g_form.setReadOnly('u_escalation_comments', false);
        g_form.setReadOnly('u_esc_by_ritm', false);
        g_form.setReadOnly('u_esc_date_time_ritm', false);
    }
}

 

That escalted field should only enable only for Tech hub team .

'while doing testing 'Gunjan ' is the tech hub team , i have impersonated with his profile 

nameisnani_4-1733881380448.png

 

I am getting this error 

nameisnani_5-1733881380443.png

 

 

And form saving fields should be gerdout

nameisnani_6-1733881380445.png

 

 

Can anyone please help me with this?

 

Please provide me the updated script.

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

seems you are having some filter on that Escalated by reference field

are you giving the correct sysId?

what happens when you select some other value in reference field?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@nameisnani 

Did you get a chance to check my above response?

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

@nameisnani 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Juhi Poddar
Kilo Patron

Hello @nameisnani 

You can create UI policy for this:

Table: sc_req_item

Condition: Assignment group: "Tech hub team"

Reverse if false: checked

Onload: checked

Save the form and then in UI action add the desired fields and set visible as true

 

Screenshot for reference:

JuhiPoddar_0-1733887378156.png

This method will not require any scripting and configuration setup will help to meet the requirement.

Note: Though we know UI policy will override client script, it is recommended to deactivate the client script and BR when not in use.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar