Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

Service Portal Survey Issue

SandeepKSingh
Kilo Sage

Hi Team,

In the image shown below I wanted to add other details of Incident like short description and priority.

Where I should change I tried in survey widget but getting Error --> surveryAPI() is not declared.

 

SandeepKSingh_0-1725009183010.png

 

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage

Hi @SandeepKSingh 

Open The Widget "My Survey"

And you need to clone the widget before do any changes.

Then Just add the below code in Server side script and HTML :-

 

Server Side :-

var triggerId = instance.trigger_id;
gs.info("Trigger ID: " + triggerId);
var incidentGR = new GlideRecord('incident');
if (triggerId && incidentGR.get(triggerId)) {
gs.info("Incident found with sys_id: " + triggerId);
instance.incident_number = incidentGR.getValue('number');
instance.incident_short_description = incidentGR.getValue('short_description');
instance.incident_state = incidentGR.getValue('state');
} else {
gs.info("No incident found with sys_id: " + triggerId);
}

 

And In HTML:-

<div>
<!-- Display additional incident details -->
<small>Incident Number: {{::instance.incident_number}}</small><br/>
<small>Short Description: {{::instance.incident_short_description}}</small><br/>
<small>State: {{::instance.incident_state}}</small><br/>
</div>

RaviGaurav_0-1725012981637.png

 

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage

Hi @SandeepKSingh 

Open The Widget "My Survey"

And you need to clone the widget before do any changes.

Then Just add the below code in Server side script and HTML :-

 

Server Side :-

var triggerId = instance.trigger_id;
gs.info("Trigger ID: " + triggerId);
var incidentGR = new GlideRecord('incident');
if (triggerId && incidentGR.get(triggerId)) {
gs.info("Incident found with sys_id: " + triggerId);
instance.incident_number = incidentGR.getValue('number');
instance.incident_short_description = incidentGR.getValue('short_description');
instance.incident_state = incidentGR.getValue('state');
} else {
gs.info("No incident found with sys_id: " + triggerId);
}

 

And In HTML:-

<div>
<!-- Display additional incident details -->
<small>Incident Number: {{::instance.incident_number}}</small><br/>
<small>Short Description: {{::instance.incident_short_description}}</small><br/>
<small>State: {{::instance.incident_state}}</small><br/>
</div>

RaviGaurav_0-1725012981637.png

 

That's Exactly it worked thanks 🙂

SandeepKSingh_0-1725020039242.png