Add Variable Editor to Custom Table

kristenankeny
Tera Guru

I have extended the sc_req_item table to create a u_required_item table, which is related to a u_position table (similar to how sc_req_item is related to sc_request, u_position is an extension of sc_request). The idea is to allow people to define the required catalog items (including variables) for a particular position. I'll then send the position through approvals, then the required items, and then once approved that position will be available on our onboarding order guide. The goal is to script the addition of the sc_req_items based on what I found in the u_required_item table for the selected position.

In order to add catalog items to a position, I am currently doing the following:

On a position, you can click "Add required item". This deletes the user's carts and opens the catalog, where they can complete items and checkout. On the default Request level workflow, I am checking to see if the Request's parent is a Position. If it is, then I am updating the RITMs and moving them to the RI (required item) table. This is that script, in case it matters:

var r = new GlideRecord('sc_req_item');

r.addQuery('request',current.sys_id);

r.query();

while(r.next()){

  var num = r.number;

  var shortnum = num.substring(4);

  var newNum = 'RI' + shortnum;

  r.setValue('sys_class_name','u_required_item');

  r.setValue('number',newNum);

  r.setValue('request',current.parent);

  r.setValue('parent',current.parent);

  r.update();

}

This seems to be working without issues (minus needing to then close the catalog window and redirect them to the window in which they have the position open - haven't started tackling that yet). However, when I view the required item, I cannot see the variables on the form. I tried creating a custom variable editor outlined in this KB: ServiceNow KB: Determining whether the Variable Editor is added to a form (KB0538897) , but it still won't show. When I check the sc_item_option_mtom table, I can see entries for my required item. I'm at a loss as to how to resolve this issue.

1 ACCEPTED SOLUTION

rishireddy
Mega Guru

Hi Kristen,



Check the "com_glideapp_servicecatalog_veditor" macro's eval_cat_item() function is been aligned with your custom table as well.



Please mark correct or helpful if this makes any impact!!!



Regards,


Rishi Reddy


View solution in original post

5 REPLIES 5

My guess is that the macro that you do not have access to (you can see it in the render component line) is expecting to be running this from either requested item or catalog task and not other tables. At the very least (because there are other formatters for other types of task tables), it is expecting to be inserted into an extension of the task table.