Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

PrashantLearnIT
Tera Sage

Do you know how to call a script in the reports and why?

There are multiple scenarios which we can not perform by the simple filters in the reports.

Example: Show all the survey response questions if response of First Question is Positive.

 

In this conditional requirement we can not achieve the complete data in the report so we can call the script Include in the Report as below.

Script Include: 

getAllSurveyResponse: function() {
 var ans =[];
 var result = new GlideRecord('asmt_assessment_instance_question');
 result.addEncodedQuery('category=c8f4ab6a0fe57a0006e25c3be1050ebb^sys_created_onONLast month@javascript:gs.beginningOfLastMonth()@javascript:gs.endOfLastMonth()^metric=53eea7a0db8f57cc4f5bf64a0c9619fb^value=1^ORvalue=2');
 result.query();
 while(result.next()){
  ans.push(result.getValue('instance'));
 }
 return ans.toString();

},

Report:

Pasted image.png

 

If my content helped you in anyway, please mark this content as BOOKMARK, SUBSCRIBE & HELPFUL

 

Best Regards,

Prashant Kumar (LearnIT)

 

YouTube Channel LearnIT: https://www.youtube.com/@learnitwithprashant

Blog LearnIT: https://medium.com/@LearnITbyPrashant

Prashant Kumar LinkedIn: https://www.linkedin.com/in/learnitbyprashant/

ServiceNow Community Prashant Kumar - https://www.servicenow.com/community/user/viewprofilepage/user-id/19635