setting variables to read only once approved

Ramel
Mega Guru

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

1 ACCEPTED SOLUTION

Ramel
Mega Guru

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


View solution in original post

23 REPLIES 23

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:


Record Producer


"


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"


find_real_file.png


2) then a UI Policy "On Load"


find_real_file.png



This on at the "Requested Item" level.




Regards,


Telmo


Hi Telmo,



that helped me a lot to replace a client script which was using DOM manipulation.



Kind regards


Miguel


mrswann
Kilo Guru

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?


Ramel
Mega Guru

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