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.

Display Variable Editor in Service Portal

reginabautista
Kilo Sage

Hi guys,

I have followed the workaround in the article in HI below...

ServiceNow KB: In Service Portal, the Variable Editor widget does not work with sc_task records and ...

I have then cloned the sp-variable-editor and embed it to the the Form cloned widget.

However the variables are still not displaying on the form.

Would you know what am I doing wrong?

find_real_file.png

1 ACCEPTED SOLUTION

reginabautista
Kilo Sage

Hi guys I have debugged the server script, the reason the variables were not displaying is because I was viewing a record created from a record producer. I had to change the code to get the record producer sysid rather than the catalog item:



var gr = new GlideRecord(data.table);


    if (gr.get(data.sys_id)) {


          var recordClassName = gr.getRecordClassName();


console.log('recordClassNamee=' +   recordClassName);


          if (recordClassName != data.table) {


                data.table = recordClassName


                gr = new GlideRecord(data.table);


                gr.get($sp.getParameter("sys_id"));


console.log('sysid=' + $sp.getParameter("sys_id"));


                }


          try {


            //var catItem = data.table == "sc_task" ? gr.request_item.cat_item : gr.cat_item;


var catItem = gr.u_record_producer;



console.log('gr.cat_item=' + gr.cat_item);


               


// data.sc_cat_item = $sp.getCatalogItem(catItem);


//regina added params to the getCAtalogItem as these were introduced after Istanbul 3a+


//catItem = '13ffd3dddbd28b40f82ada94ce9619e3';


data.sc_cat_item = $sp.getCatalogItem(catItem,false);


View solution in original post

13 REPLIES 13

michaelskae
ServiceNow Employee
ServiceNow Employee

Hi Regina,



The KB article works for many versions, but after Istanbul patch 3, there is a change to the getCatalogItem class.


If you notice the comments section of the article, Vincent Hu suggests a change:



Feedback Posted by Vincent Hu (NOW) on 2017-10-03 07:43:57


The workaround provided works well for Istanbul before 3a.
In Istanbul 3a+ need to be modified as it is still using $sp.getCatalogItem(catItem). Should modify it to $sp.getCatalogItem(catItem,!!options.isOrdering, data.table);



See KB0621849.



Does this help?



Mike


Hi Michael thanks for the reply.



I am getting the below error when I added params to the getCatalogItem:



js_includes_sp.jsx:71268 Error loading the variable editor: InternalError: Can't find method com.glide.service_portal.widget.SPScriptable.getCatalogItem(java.lang.String,boolean,string). (<refname>; line 35)



If I remove the last param (data.table) this is what I'm getting:


js_includes_sp.jsx?v=05-05-2017_1035&lp=Mon_Nov_06_01_40_29_PST_2017&c=19_66:3390 The specified value "!" does not conform to the required format.   The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.


I am using Build tag: glide-istanbul-09-23-2016__patch5-hotfix1-05-04-2017


If you notice in sp_ui_formatter table. There is a formatter called "com_glideapp_servicecatalog_veditor".


You need to create a new formatter   with this name as well in formatter table for which ever table you need and add that formatter in the form layout as well


Regards
Harish