need help in script

nameisnani
Mega Sage

Hi Team , 

 

can anyone please help me with this issue 

 

In RITM form i have configured custom fields 

nameisnani_0-1733725755896.png

 

I have wirtten business rule and cilent script for this 

nameisnani_1-1733725889378.png

nameisnani_2-1733725918609.png

 

cilent script 

nameisnani_3-1733725966386.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-1733726131026.png

I am getting this error 

nameisnani_5-1733726204410.png

 

And form saving fields should be gerdout

nameisnani_6-1733726283080.png

 

Can anyone please help me with this?

 

Please provide me the updated script.

 

6 REPLIES 6

Anand Kumar P
Giga Patron
Giga Patron

HI @nameisnani ,

 

Your onload client script update like below

Business rule script:

 if (gs.getUser().isMemberOf('AVN-TechHub-SUP') || gs.getUser().isMemberOf('CFS_ITOperations_OPS_APR') || gs.getUser().isMemberOf('TFS-MID WEST')) {
        g_scratchpad.ritmvisible= 'true';
    } else {
        g_scratchpad.ritmvisible= 'false';
}

Client script:
function onLoad() {
    if (g_scratchpad.ritmvisble=='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  {
//Why you are making both places readonly if part of group make readonly false else make readonly true
        g_form.setReadOnly('u_escalation', true);
        g_form.setReadOnly('u_escalation_comments', true);
        g_form.setReadOnly('u_esc_by_ritm', true);
        g_form.setReadOnly('u_esc_date_time_ritm', true);
    }
}

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

@Anand Kumar P 

 

Let me try and check 

@Juhi Poddar @Anand Kumar P 

 

@Anand Kumar P  Still same issue 

 

match not found , reset to original .

nameisnani_0-1733730285909.png

 

Hi @nameisnani ,

First check  the filled value in location  is valid or not.

Check the scripts which is setting value of a reference field 

While setting the value of reference through client script,

we should set both value and display value like the below

g_form.setValue('u_field_reference', value, displayValue) ;

Refer below links
https://www.servicenow.com/community/now-platform-forum/how-to-solve-the-quot-match-not-found-reset-...

https://www.servicenow.com/community/itsm-forum/error-occurs-when-i-save-the-incident-invalid-update...

https://www.servicenow.com/community/developer-forum/error-message-invalid-update-match-not-found-re...

 

https://www.servicenow.com/community/itsm-forum/match-not-found-reset-to-original-error-while-saving...

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand