Service Portal - Create data table of child tasks when opening the parent?

robhaas
Tera Contributor

In service portal, I am using the ticket form and referencing TableA (the parent table in this scenario). When this page opens and displays the ticket information, I want to show a table as well that contains all child tasks from TableB with the parent# of the incident I have open on this page. The URL shows the SYS_ID of the parent item, so I'm assuming there may be a way to use table by url definition maybe? I'm not really sure.

Anyone have any insight on how I could accomplish this? Below is the sample URL:

https://xxxx.service-now.com/arp?sys_id=7bc590531387a60002bb7d576144b0c9&view=sp&id=test_ticket&tabl...

Tagging a few people from previous posts as well. Hope you don't mind!

paulw(acorio)

b-rad

1 ACCEPTED SOLUTION
24 REPLIES 24

No problem Robert,
      If you could send me a picture of your url that would help me. However I am gonna assume some things and you can give this a try in the server side code of your simple list widget. (I am also assuming what reference field you are using for parent task)



______________________________________________________



var currentTaskID = $sp.getParameter("sys_id");


var taskGR = new GlideRecord('task');


taskGR.addQuery('sys_id', currentTaskID);


taskGR.query();



var encodedQuery = '';


if ( taskGR.next() ) {


  encodedQuery = 'parent.sys_id=' + taskGR.parent.sys_id + '';


}



//Replace what options.filter means


var options.filter = encodedQuery;



______________________________________________________



I hope this helps, let me know if you have anymore questions.



Best Regards,


      Philip Engles


      philip.engles@techport13.com


find_real_file.png


How would I replace the options.filter? The below is what code shows for options.filter:



gr.addEncodedQuery(options.filter);


options.title = options.title || gr.getPlural();


options.display_field = $sp.getParameter('f') || options.display_field;


if (!options.display_field || !gr.isValidField(options.display_field))


options.display_field = gr.getDisplayName();




if (input && input.filterText) {


gr.addEncodedQuery(options.display_field + "LIKE" + input.filterText)


}




options.title = options.title || gr.getPlural();


options.secondary_fields = options.secondary_fields || "";


options.secondary_fields = options.secondary_fields.split(",");


if (!options.order_by || !gr.isValidField(options.order_by))


options.order_by = options.display_field;


Hi Robert,
      Sorry I mislead you a little with declaring the options.filter.



Please just set your server side code how I have it pictured:
find_real_file.png



Best,


  Philip E.


Ok, that make sense. From that point, I need to get the new encodedQuery in as the parent.sys_id on the table from instance definition widget. So if I set the table to "task". I need the parent.sys_id = encodedQuery since that will be the sys_id of the opened record.


Seems like I was able to help If you could do me a favor and mark my response as an answer to your question I would greatly appreciate it! BTW it would be the is the "current" task ticket's parent's sys_id. I would do some reading on Dot Walking you can see I did a manual dot walk when I created my encoded query string.