How to Get variable value to a form field...

arun170909
Kilo Contributor

Created a catalog item 'Request for Software'. Add the below variables to it

  • Requested for — reference to user table
  • Manufacturer — reference to 'Manufacturer' table
  • Software — reference to 'Software' table
  • Business justification — Multiline text

Created a field 'Software' on 'Request' table and once the request is submitted, This field should have the value selected by the user for 'Software' variable in 'Request for Software'. Change the form lay out to show this field on Request item form.

Plz Help to slove this ....

Thanks in Advance.

Arun.T

1 ACCEPTED SOLUTION

Manoj Kumar16
Giga Guru

Hi Arun,



You can access the value of the variable in your workflow. You can access it by- current.variables.software this will be a sys_id of the record.



Similarly you can store the value in the request table by accessing the request tables variable as - current.request.software you just have to pass the variables in the workflow.



Write a runscript activity in the workflow attached in 'Request for Software' and modify the below code with the variable names and update-



var gr= new GlideRecord('sc_request');


gr.addQuery('sys_id',current.request);


gr.query();


if(gr.next())


{


gr.field_name_of_software_in_request_table=current.variables.variable_name_of_software_in_catalog_item;


gr.update();


}



You can add this field in request item as well by configuring form layout.


View solution in original post

5 REPLIES 5

It isn't necessarily the requested_for field as that person might be submitting on behalf of someone else. So, I have a field on the catalog item called, "Ask on behalf of this user." The field auto-populates with the "requested for" person, but it can be over-written with someone else's name if needed. I then have some "on-change" scripts that update phone numbers, cost centers, employee numbers, mangers, etc... It is that manager field that is being updated based on who is in that "Ask on behalf of this user" field that needs to transfer into the RITM and ultimately receive the notification.



I did try the script you wrote above. There seems to be a problem when I send to a reference field on the RITM form. It works just fine if the receiving field on the form is a string field, but it does not work if the receiving field is a reference field. However, I believe I need it to be a reference field so I can use it in the notification.



I have also tried figuring out a way to send the notification in the workflow. (I don't need it to be a reference field on the RITM if I can get the notification to send in the workflow. I just need it to record on the RITM so team members know who received it). I was unsuccessful with that as well.



Originally I had a bit of javascript in the Set Value box to match the variable to the field on the form on the RITM, but ever since we did the "Instance Hardening" that script no longer works.



Thanks for your help. I'll keep plugging away at it.



Richelle