Using script include while constructing query in URL(from arguments ) in navigation link

adarshshivaprak
Kilo Contributor

Hello All ,

We had a requirement to show all open incidents which are tagged to the logged in   user. The entitlement is done on the user table.

Can we use script include while constructing URL (from arguments) along with fixed query to show the incidents returned by script include .

EG :

1.     incident_list.do?sysparm_fixed_query=caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^active=true

Including script include :

2.     incident_list.do?sysparm_fixed_query=caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^active=true&javascript:new INC_Selection().getincident().

Only the first query is working and the second is not working .

Any suggestion on how we can achieve it .

Thanks ,

Adarsh S

11 REPLIES 11

Hi Adarsh,



Forgive me, I'm not sure if that was a question, issue, or statement. Was there anything more I can provide to help you answer your initial inquiry?


adarshshivaprak
Kilo Contributor

I am sorry . That was a question .   Could you please help me out the way where we can construct a query which will includes the result obtained from script include.


Hi Adarsh,



The script include only needs to output a string. Your module calls it something like this:



incident_list.do?sysparm_fixed_query=javascript:myScriptInclude()


I'm trying this out , Chuck, and my module isn't displaying what I would like. I got my script to work in the background scripts, but I'm gs.print or gs.log.


I want to return an Incident or many Incidents.


I am wanting to return children Inc that have a date/time of 5 minutes or more after their parent.



Here is my script.


function matchParentIncToChildInc() {


  var gp = ' ';


  var cou = new GlideRecord('incident');


  cou.addEncodedQuery('u_testISNOTEMPTY^parent_incident.u_testISNOTEMPTY^parent_incidentISNOTEMPTY');


  cou.query();


  while(cou.next()){


  var dteP = cou.parent_incident.number;


  var dte = new GlideDateTime(cou.parent_incident.u_test);



  //5 mins * 60 seconds = 300


  dte.addSeconds(300);


  // gs.log("dte Before " + dte);


  dte.subtract(25200000 );


  // gs.log(" Parent " + dteP);


  // gs.log("dte After" + dte);


  // gs.log(cou.number);


  if(cou.u_test >= dte)


  {


  gp += (',' + cou.sys_id);


  //gs.log("this worked and will populate a list of incidents");



  //gs.print(cou.number);


  }


  }


  return gp;


}


Hi Sam



Since you are returning list of sysids, you need to update your url to below:



sysparm_fixed_query=caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^active=true&Sys_idsINjavascript:new INC_Selection().getincident().