- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 08:56 AM
Hi Everyone,
I have a requirement where I need to Auto Populate fields on the incident form after submitting the Record Producer.
I have a reference variable "abc" on the Record Producer which refers to the location table. I need to get the details like "city", "street", "country" from the location record I select on the variable "abc" and need to auto populate the fields "city", "street", "country" on the Incident form once the record is submitted through record producer.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 09:31 AM
Hi @Nishant26,
You can write the script in the record producer script section. you can write something similar to the below code.
var gr = new GlideRecord('cmn_location');
gr.addQuery('name',producer.location_field.getDisplayValue());//replace location_field with the correct field name
gr.query();
if(gr.next()){
current.city= gr.city; //current. sets the field value on the Incident form
curent.country = gr.country;
current.street = gr.street;
}
Mark this answer as correct and helpful if it solves your issue.
Regards,
Siva Jyothi M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 09:31 AM
Hi @Nishant26,
You can write the script in the record producer script section. you can write something similar to the below code.
var gr = new GlideRecord('cmn_location');
gr.addQuery('name',producer.location_field.getDisplayValue());//replace location_field with the correct field name
gr.query();
if(gr.next()){
current.city= gr.city; //current. sets the field value on the Incident form
curent.country = gr.country;
current.street = gr.street;
}
Mark this answer as correct and helpful if it solves your issue.
Regards,
Siva Jyothi M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2023 08:34 PM
Please mark the answer as correct if it solves your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 09:39 AM - edited 09-05-2023 09:40 AM
As the Script field on a Record Producer runs on the server, not the client, you can dot-walk the reference variable value, so you only need a line like this for each field on the incident that you want to populate.
current.city = producer.abc.city;
Where 'city' is the name of a field on the incident table (current) and on the variable referenced location table (producer.abc).