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
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

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage
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

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

That's Exactly it worked thanks 🙂

SandeepKSingh_0-1725020039242.png