- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 08:10 AM
Hi All, Need a little help why my onload script does not work. My concern is to be able to set the variables to read only after approval. Anyone can confirm about my 'if' statement? It doesn't work. function onLoad(){ //Type appropriate comment here, and begin script below if(g_form.getValue('approval' == 'approved')){ g_form.setReadOnly("variables.variable_name", true); I tested without the if condition and the field is being set to ReadOnly, so I can confirm that my if statement is incorrect. Anyone can advise? Thanks in advance. Ramel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 07:39 AM
My issue was resolved by using g_form.getReference('parent'); then if condition which is approval = approved. With that I was able to set the variables in the task as readonly after approval.
Thanks all for the replies

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 05:28 AM
Hi Ramel,
I think I understood yes.
For creating a request you shouldn't be using a Record Producer. As per ServiceNow recomendation, and also I don't see the advantage of using it.
From the wiki:
"
Note: To ensure that standard service catalog processes are followed, such as initiating workflows as expected, do not create requested item records from record producers. Instead, create requested item using catalog items.
"
Meaning, I don't you use a regular catalog item, that has the variables you want and that uses your workflow.
If you use a regular Catalog Item, you could use the suggestion already given before to make the variables not editable. (Catalog UI Policy, Client Script).
I have done this way for making all variables readonly for all catalog items:
1) Business rule "On Display"
2) then a UI Policy "On Load"
This on at the "Requested Item" level.
Regards,
Telmo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2018 04:05 AM
Hi Telmo,
that helped me a lot to replace a client script which was using DOM manipulation.
Kind regards
Miguel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 03:23 AM
I don't fully understand.
You have a record producer for the point at which you are raising your request?
At this stage, how could it be approved - if it doesn't exist?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 07:39 AM
My issue was resolved by using g_form.getReference('parent'); then if condition which is approval = approved. With that I was able to set the variables in the task as readonly after approval.
Thanks all for the replies