Service Portal Developement

sagar patil2312
Tera Contributor

I am trying to develope servicenow portal my scenario is that when i create the incident by caller who is system administratior from service portal at that time it will be populate service portal thats why i am writing code in

SERVICE PORTAL LIKE THIS 

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
data.Inc = [];
 var grInc = new GlideRecord("incident");
gs.debug();
gs.info("Incident starting to create");
grInc.addQuery('caller_id' + gs.getUserID());
grInc.query();
while(grInc.next()){
gs.info('Incident Found');
data.number = grInc.number.toString();
data.short_description = grInc.short_description.toString();
data.caller_id = grInc.getValue(caller_id);
  data.Inc.push(json);
}
 
})()
 
IN HTML TEMPLATE I WRITE THE CODE LIKE THIS.
<div>
<!-- your widget template -->
<h1>
Incident Details
</h1>
<p>
You Will get Incident Details
</p>
<table>
<tr>
<th>number</th>
<th>short Description</th>
<th>caller</th>
</tr>
<tr>
<td>{{data.number}}</td>
<td>{{data.short_description}}</td>
<td>{{data.caller_id}} </td>
</tr>
</table>

</div>
 
AND MY UNEXPECTED TESULT IS

Incident Details

You Will get Incident Details

number short Description caller

 

 

WHY INCIDENT IS DATA IS NOT POPULATE IN THIS SCENARIO PLEASE HELP ME TO GET OUT OF THIS.

2 ACCEPTED SOLUTIONS

Community Alums
Not applicable

Hi @sagar patil2312 ,

Here in your script the issue is 

Inside while loop yoi are doing

grInc.getValue(caller_id)

Which is not correct instead of that you have to do like

grInc.getValue('caller_id');

It should be in string 

 

Please mark my answer correct and helpful if this works for you 

 

Thanks and Regards 

Sarthak 

View solution in original post

i dont think your query line is right....  line 5 in the server script, id adjust this to:

grInc.addQuery('caller_id', gs.getUserID());

View solution in original post

13 REPLIES 13

hii sarthan your ans is great but my problem is this is not working in my pdi.

Community Alums
Not applicable

Hi @sagar patil2312 ,

Can you please share me some images for reference. This would be help

 

Thanks and Regards 

Sarthak

sagar patil2312
Tera Contributor

your ans is write bro this is not run in my instance that is my problem.

sagar patil2312
Tera Contributor

hii sarthak i am greatful for you answer but your answer is not work in my pdi my issue is that while i am writing server screapt for gliding incident record which is not trigger

4fd74772-c101-4958-9bcf-9b6e6ab3dbfd.jpg

Community Alums
Not applicable

Hi @sagar patil2312 ,

Here in your script the issue is 

Inside while loop yoi are doing

grInc.getValue(caller_id)

Which is not correct instead of that you have to do like

grInc.getValue('caller_id');

It should be in string 

 

Please mark my answer correct and helpful if this works for you 

 

Thanks and Regards 

Sarthak