Populate Record Producer variables based on another variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2013 08:55 PM
I'll make this short just as an example. I have a record producer which has the variables below.
Variable 1:
resolution_ticket_number
- Lookup from u_another_table using reference type which has a field with the same information as the field below in variable 2 and is also a string field.
Variable 2:
u_certain_number_2
- String field
When the user is filling out the record producer fields, I would like to populate variable 2 with the data in the table from variable 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2013 12:07 PM
Hi,
You should be able to get this using client script on the record producer available.
]Write a client script on change of variable 1. Get the reference of the record either by using g_form.variable_name.getReference() or using ajax call to retrieve the required value from the table and populate on the variable 2.
Refer below URL for client scripting.
http://wiki.servicenow.com/index.php?title=Creating_a_Catalog_Client_Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 08:28 AM
Prashant,
Thank you for your reply. I have tested several scripts, but being new to scripting isn't helping! I've attached a screenshot as my original description may not have done justice. The script will run when the user fills in the Resolution Desk Number on the record producer. It will populate the two fields mentioned below while still on the record producer form.
Per the screenshot, the Resolution Desk Number is a reference to a u_lending table. The u_lending table has two string fields: u_loan and u_cst_ticket.
I would like to "get" the value of the u_loan and u_cst_ticket fields based on the LS ticket typed in the Resolution Desk Number (u_resolution_number) field and then populate those values in the two corresponding fields above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2013 08:58 AM
use this script in Catalog Client script onchange of variable name resolution ticket number.
var xnum = g_form.getValue('variables.resolution_desk_number');
var gr = new GlideRecord('u_lending');
gr.addquery('resolution_desk_number', xnum);
gr.query();
while (gr.next())
{
g_form.setValue('variables.cst_ticket_number',gr.u_cst_ticket);
g_form.serValue('variables.original_requestor', gr.u_loan.sys_id);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2013 10:22 AM
ravi1 - I appreciate your help. Unfortunately, the script isn't populating any of the fields. I've tried several different ways and searched the community and wiki, but still no results. Below is a pasted layout if you or someone else has time to review. Thank you!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
***Record Producer :***
Uses table u_lending_services_air. Sends data from record producer to that table.
Variables:
•resolution_desk_number ---- lookup reference from u_lending_services table
•cst_ticket_number --- string field
•customer_name --- string field
•account_loan_number --- string field
***Table 1: u_lending_services***
Variables:
•number --- string with default value "javascript:getNextObjNumberPadded();" which increments 1 number for each ticket
•u_cst_ticket_number --- string field
•u_customer_name --- string field
•u_loan_number --- string field
***GOAL: ***
1.User chooses a Resolution Desk Number from the lookup box that pulls from the u_lending_services table.
2.A script will run to pull the information FROM the u_lending_services table FOR the number chosen and populate that ticket's information in the record producer variable fields mentioned above.
