How to Auto Populate fields from record producer to form

Nishant26
Tera Contributor

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!

1 ACCEPTED SOLUTION

Siva Jyothi M
Mega Sage

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.

View solution in original post

3 REPLIES 3

Siva Jyothi M
Mega Sage

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.

@Nishant26,

Please mark the answer as correct if it solves your issue.

Brad Bowman
Kilo Patron
Kilo Patron

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).