Querying servicenow incident table

Phalguna
Mega Contributor

Hi  I have following requirements on service now Incident table

1.I need to get the records based on the caller field(I could able to get using created by filed but not with caller)

var gr=new GlideRecord('incident');
//gr.orderByDesc('sys_updated_on');
gr.addQuery('sys_created_by',name);
gr.query();
while(gr.next()){
var count= gr.getRowCount();
inc.push({
'Number':gr.number+'',
'state':gr.state.getDisplayValue()+'',
'short_description':gr.short_description+'',
'assignment_group':gr.assignment_group+'',
'priority':gr.priority.getDisplayValue()+'',
'created By':gr.sys_created_by

2.How can I updated the created by filed ,actually its always  taking instance holder name for this filed(from my application I am trying to pass the different created by name in the payload of this api)

3. How can i return entire row from the incident table based on the passed incident number,

 

Regards,

Phalguna.

 

1 ACCEPTED SOLUTION

Thanks a lot,its working .

View solution in original post

3 REPLIES 3

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Phalguna,

1. Replace gr.addQuery('sys_created_by',name); with gr.addQuery('caller_id.user_name',name);

2. Refer https://community.servicenow.com/community?id=community_question&sys_id=7cbeb2a5db58dbc01dcaf3231f96...

3. Sample CURL code

curl "https://YOURINSTANCENAME.service-now.com/api/now/table/incident?sysparm_query=number%3DINC0009005&sysparm_limit=1" \
--request GET \
--header "Accept:application/json" \
--user 'admin':'admin'

https://developer.servicenow.com/dev.do#!/learn/learning-plans/orlando/technology_partner_program/ap...


- Pradeep Sharma

 

Thanks a lot,its working .

You are very welcome Phalguna.