Is it possible to edit the \$sp.getCatalogItem(data.sys_id, true); method?

chethann
Giga Contributor

Hi All,

I have to modify the data getting from $sp.getCatalogItem(data.sys_id, true); method. can edit it.

If yes, How to edit?

Thanks.

4 REPLIES 4

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

It's not possible, as this method is defined inside the core code.


vidisha4
Giga Expert

Hello Chetan,



You can try below code:



data.sc_cat_item = $sp.getCatalogItem(data.sys_id, true);


if (data.sc_cat_item.sys_id= 'item sys_id')


{


//I think Based on above condition you can modify the data


}


xiaix
Tera Guru

I need the same.  I put a custom true/false flag on the item_option_new table, and need to be able to read that value before the form loads on the SP.

So... even though $sp.getCatalogItem() may not be interceptable, I believe there's a solution to my need.  I'll post back with my results.

So, my personal requirement was to have Catalog Item Variables that were not visible/interactable when filling out and submitting the form, but were only to be used/interacted with by Fulfillers that worked the Catalog Task (sc_task) generated by the workflow. 

Think of it as a "Fulfiller only" variable set.  This is extremely valuable to us because we wanted to make workflow decisions made based on variable options that the fulfiller chose.

Anyway... the first part was to add a new field on the Variable (item_option_new) table:

find_real_file.png

 

Here is when I choose it:

find_real_file.png

 

Now, here is how I make it truly "Not Visible" on the form:

I edit the Server Script portion of the widget that displays a catalog item form, then I change 1 line, and add 1 function.

Here is the line I edit (my addition is highlighted):

find_real_file.png

 

And here's the function:

find_real_file.png

 

I hope someone out there finds this useful.