Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Record Producer to set value in table

Elizabeth26
Tera Contributor

I am trying to set a value in the destination table of where a record producer is sent.

 

I tried within the script part of the record producer and also catalog client script but neither seem to work. I am not sure which option is better. I have tried in the script producer and current. It works for other things I am mapping this way in the script but not sure why it's not working for these? 

 

if (producer.x_location_type == 'Facility') {
current.x_on_premises_selection = "Building";

}

if (producer.x_location_type == 'Non-Site Facility') {
current.x_off_premises_selection = "Site";

}

17 REPLIES 17

Rahul RJ
Giga Sage

@Elizabeth26x_location_type  field is a reference field or choice field if it's choice field then you can check choice value and it's reference field then check with sysid of the location type

 

var location = producer.x_location_type;

if (location == 'Facility') { //can you check the choice value is same or different it should match with the target table field choice value
      current.x_on_premises_selection = "Building"; //x_on_premises_selection is choice field they we can assign choice value to the same
}
if (location == 'Non-Site Facility') {
     current.x_off_premises_selection = "Site";
}

 

Regards,

RJ

It's a choice field. The choice values do match the values I am using.

@Elizabeth26  are you able to log the location type value in the script gs.info(producer.x_location_type) Can you share the log?

 

Regards,

RJ

@Elizabeth26,

Can you share some screenshots of your field and choice list.  Is your choice field referencing a table?

So, the table the choice list references is different that the table I am opening the record producer in. Do I have to reference it? 

 

Should I also use the script in the record producer or a catalog client script?