Restrict location field value change when assigned to changes in hardware asset table

Andrew161
Tera Contributor

Hello everyone, 

I have a requirement where I have to restrict the on-change client script "Set Loc/CC/Dep/Com from assigned to" in the alm_asset table from changing the location and other fields when the substate is set as leaver. 

I set the substate value via a transform map and if it is set as Leaver then whenever the assigned to is changed the location value should not be changed. 

Any suggestions is appreciated.

 

-Andy

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Andrew161 

why not make that location field as read only when form loads and in that onLoad client script check substate=leaver

function onLoad() {

    if (g_form.getValue('substate') == 'Leaver')
        g_form.setReadOnly('location', true);

}

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

@Andrew161 

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

Hi @Ankur Bawiskar

Thanks for the response. 

The location field is changed in the background by client script, so even after making it read-only it is getting amended. 

I am trying alternate option.

 

@Andrew161 

which client script is doing that?

I didn't get your business requirement

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