View Variable of a RITM in a simple list (Portal)

gml35
Tera Guru

Hi All,

I'm looking to give users a view of their past request of a particular item by creating a simple list on the portal and filtering by the item.   The issue I'm running into is that there is no way to pull the variables from the RITM.   Has anyone done this already?   I'd imagine it's a pretty common ask out there?

I appreciate any help you all can provide!!!

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Glenn,



The first thing to note is that you will need a customer widget to do this. It's not available OOB because every RITM has different variables so there's no easy way to display them in a list.



If you choose to write a custom widget, you'll need to "load up" the data object for each record with the variables in the server script. Pretty straight forward when it comes to getting variables and values.



You can use this code in a mail script to print variables. This one assumes the message is on the sysapproval_approver table and gets the variables from the record pointed to by the sysapproval table. Below is a code snippet I use to get variable values for an approval record in to an email template. You can adjust the bold lines to your needs in the widget.




printVars();


function printVars(){


      var set = new GlideappVariablePoolQuestionSet();


      set.setRequestID(current.getValue('sysapproval'));


      set.load();


      var vs = set.getFlatQuestions();


      for (var i=0; i < vs.size(); i++) {


              if(vs.get(i).getLabel() != '') {


                      template.print('       ' +   vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");


              }


      }


}


View solution in original post

15 REPLIES 15

Here is a snippet of my current simple list.   I'm trying to add more items to the Secondary Fields. I'm new to portal so I have some catching up to do on the custom widget side.


find_real_file.png


on the same lines i wanna display the variables in the email. 

earlier i was using something like :

var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", current.request_item.number);
gr.query();
var a =0;
while(gr.next()) {
template.print(gr.number + ":" + gr.cat_item.getDisplayValue() + "\n");
template.print(" Options:\n");
//template.space(4);
//template.print('<b>'+ Requested For+'</b>' ='+gr.variables.requested_for.getDisplayValue()+"\n"+"\n");

for (var key in gr.variables) {
var v = gr.variables[key];

template.print(' ' +'<b>'+v.getGlideObject().getQuestion().getLabel()+'</b>' + " = " + v.getDisplayValue() + "\n"); 

 

but now its not picking all the variables and instead stopping after 5 variables. 

earlier it was all good. Is there any restriction with London release ?

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Glenn,



RITM Variables you cannot show directly on RITM list view.


You can create a report and show the information which will point to the Variable Ownership table.


But the issue will be the report will be specific to particular catalog item


This table stores details about variable values which user submitted for corresponding RITM number.



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI Glenn,



Why you want to pull variables of RITM? Because as per your question i see that you just want to show them there past RITM?



If i understood this correctly then you want a user to view all variables associated with RITM's, once they click on That ritm and get redirected?



Here we have to create new Widget as a whole and then need to show them.



Thanks,


Hi ashutoshm1,



The requirement is to list the items from a RITM in a single list on the portal with fields from the input form like price vendor etc.   They do not want to have to click around to find a request.



Glenn