getDisplayValue()

Joshuu
Kilo Sage

Hi All,

 

I have written below script for incident creation through inbound integration. And I am using "getDisplayValue()" to insert the actual Display name from source instance.

 

But it is not working. Please correct me if I am wrong with this approach. 

 

 CRinc.initialize();

                    CRinc.correlation_id= reqeustJSONParser.id.getDisplayValue();
                    CRinc.state = reqeustJSONParser.state.getDisplayValue();
                    CRinc.hold_reason = reqeustJSONParser.hold_reason.getDisplayValue();
                    CRinc.description = reqeustJSONParser.description.getDisplayValue();
                    CRinc.short_description = reqeustJSONParser.short_description.getDisplayValue();
                    CRinc.sys_class_name = reqeustJSONParser.ticket_type.getDisplayValue();
                    CRinc.category = reqeustJSONParser.category.getDisplayValue();
                    CRinc.impact = reqeustJSONParser.impact.getDisplayValue();
                    CRinc.urgency = reqeustJSONParser.urgency.getDisplayValue();
                    CRinc.priority = reqeustJSONParser.priority.getDisplayValue();
                    CRinc.subcategory = reqeustJSONParser.subcategory.getDisplayValue();
                    CRinc.cmdb_ci = reqeustJSONParser.cmdb_ci.getDisplayValue();
                    CRinc.contact_type = reqeustJSONParser.contact_type.getDisplayValue();
                    CRinc.assignment_group = reqeustJSONParser.assignment_group.getDisplayValue();
                    CRinc.close_notes = reqeustJSONParser.close_notes.getDisplayValue();
                    CRinc.close_code = reqeustJSONParser.close_code.getDisplayValue();
                    CRinc.work_notes = reqeustJSONParser.work_notes.getDisplayValue();
                    CRinc.comments = reqeustJSONParser.comments.getDisplayValue();

                    CRinc.insert();

 

Please help.

 

Thanks,

Priya.

7 REPLIES 7

Hi Anurag,

 

Can you explain me briefly, how can I use this for state field?

How are you processing the incoming request?

-Anurag

If the display values in the payload are an exact match to your instance and other mandatory field requirements are met for the update (which they must be if setting the numerical value works) then you should be able to use setDisplayValue(‘fieldname’, theValue);

GlideRecord | ServiceNow Developers

Something like this

CRinc.setDisplayValue('state', yourPayLoadName.state);