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

So you can gliderecord on approval table and verify the same condition.


telmo
Tera Expert

Hi Ramel,



Somethings doesn't seem good.


You said you are using a record producer. What is the target table?



You are refering to approvers... So, are you creating requests through a record producer?



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.


"



Telmo


Hi Telmo,



Sorry for the confusion. Yes it is a record producer. Actually I am wrong about stating the target table being the   approval table. I just found out that there is a hidden field in the request form for the approval and now after approval the choice value is approved. So I changed my code to



function onLoad(){


          if(parent.approval == 'approved') { // since the approval is on the request level and this script is on task level


          g_form.setReadOnly('variables.variable_name', true);


}



Still it is not working.. What could have been missing?



Thanks,


Ramel


Hi Ramel,



Ok, it is a recorder producer. The target table was the "approval table", what is now the target table?



Or what are you trying to accomplish with the record producer? What will be the outcome after submiting the Record producer?





Telmo


Hi Telmo,



I have a record producer that is used to raise a request. Once request is created, it will have create tasks as well. Succeeding tasks will be created once the first task is closed. In the tasks created, I pass variables from the record producer to the task level via the workflow. I can already those variables from the record producer to the task but those variables need to be set as readonly after approval. From the creation of the request, one task is created and once that task is closed, approvals are required. So approvers have to approve, and once approved new task will be created. From the new task created after approval, that is where I want the variables to be set as readonly. I found that in the request form, there is hidden approval field where the value changes to approved once the approvers approved. But I cannot make my onload client script to work in a way that some variables in the newly created task will set as readonly. And that is what my issue is. Hope that makes it clear



Thanks


Ramel