Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Random Request Report

kanielb1
Mega Expert

Is it possible to create a report that pulls random cases/requests based on the assigned to?

Or how could I create a page or module that would pull a random list of records based on the assigned to in a scoped application?

1 ACCEPTED SOLUTION

kanielb1
Mega Expert

I found the following solution on another community post.


Create a UI Page:


[CODE]


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<script>


      window.onload = function() {


  randomCase();


};


      </script>    


</j:jelly>


[/CODE]



Client Script:


[CODE]


function randomCase(){


      var caseList = [];


      var rec = new GlideRecord('table');


      rec.addQuery('active', true);


      rec.addQuery('investigator', 'IN', 'Name1,Name2,Name3,Name4');


      rec.query();



      while (rec.next()){


              caseList.push(rec.getValue('number'));


      }


   


      var random = Math.floor((Math.random() * caseList.length));


      var selected = caseList[random];



      var txt = selected;



      window.location = ("https://instance.service-now.com/nav_to.do?uri=x_whba_table.do?sysparm_query=number=" + selected);



}


[/CODE]


View solution in original post

6 REPLIES 6

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Kaniel,



You can create a report and pull the results as per defined filter


.Reporting - ServiceNow Wiki


I need something like a random ticket number generator...a way to pull a random ticket for audit purposes.   Can this be done with a report?


kanielb1
Mega Expert

I found the following solution on another community post.


Create a UI Page:


[CODE]


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<script>


      window.onload = function() {


  randomCase();


};


      </script>    


</j:jelly>


[/CODE]



Client Script:


[CODE]


function randomCase(){


      var caseList = [];


      var rec = new GlideRecord('table');


      rec.addQuery('active', true);


      rec.addQuery('investigator', 'IN', 'Name1,Name2,Name3,Name4');


      rec.query();



      while (rec.next()){


              caseList.push(rec.getValue('number'));


      }


   


      var random = Math.floor((Math.random() * caseList.length));


      var selected = caseList[random];



      var txt = selected;



      window.location = ("https://instance.service-now.com/nav_to.do?uri=x_whba_table.do?sysparm_query=number=" + selected);



}


[/CODE]


But how it pulls the report based on assigned to user here?