Get complete list of reference value and corresponding display values for certain fields

karanpreet
Tera Guru

Hi,

I'm new to service now so and I'm having some issues in getting the reference values for the display values.

I'm trying to create some incidents using the REST api and I want to populate the assignment group fields from the third party tool creating the tickets. Since it's a reference field, if I send the value it shows up as a reference and not as a display value.

Is there a way to either send the Display value and not the reference value or to get a complete list of values for that particular field and do a look up before sending the values??

Thanks and any help is much appreciated.

Regards,

Karan

1 ACCEPTED SOLUTION

Geoffrey2
ServiceNow Employee
ServiceNow Employee

Hi Karen,



I agree with Chuck.   Best practice is to use an Inbound Web Service Import Set. Then you can send the display values and they will be automatically mapped to the correct sys_id.



I also recommend making use of the REST API Explorer.   It has been an invaluable tool with all the REST integrations I have done.   You can see in the Explorer that there is a parameter, called sysparm_input_display_value, you can add which will allow you to pass display values into reference fields. Use this if you need to POST directly into a table.



Screen Shot 2016-09-01 at 12.04.44 AM.png


View solution in original post

3 REPLIES 3

Chuck Tomasi
Tera Patron

Hi Karan,



You can do this by using the import set API rather than the direct table API. This allows you to use a transform map (and scripts if needed) to manipulate the data before it hits the target table. Worst cast, you can use the setDisplayValue() method to have the system do a lookup/match on the display value to turn it in to a sys_id for that reference field.


Example:



target.assignment_group.setDisplayValue(source.groupName);



Getting Started with REST - ServiceNow Wiki


REST API Explorer - ServiceNow Wiki


REST API



Create a transform map    


Geoffrey2
ServiceNow Employee
ServiceNow Employee

Hi Karen,



I agree with Chuck.   Best practice is to use an Inbound Web Service Import Set. Then you can send the display values and they will be automatically mapped to the correct sys_id.



I also recommend making use of the REST API Explorer.   It has been an invaluable tool with all the REST integrations I have done.   You can see in the Explorer that there is a parameter, called sysparm_input_display_value, you can add which will allow you to pass display values into reference fields. Use this if you need to POST directly into a table.



Screen Shot 2016-09-01 at 12.04.44 AM.png


Thanks Geoffrey!!!



That was exactly what I needed!