Can I put the Variable Editor on a new table extended from the Task table?

Wayne Richmond
Tera Guru

Hello everyone. I am trying to think of the best approach for building new request forms for a different area of the business. It will be in the style of an Order Guide so the user can complete an initial form followed by several other forms depending on their selections. These forms should appear as separate requests like they to with Catalog Item, i.e. a Requested Item with different variables depending on the item chosen. I don't really want to create a Catalog Item as it will use the Requested Item table which has many fields not related to this area of the business, e.g. Service and Resolution etc. I am considering creating a new Application that extends off of the Task table, however I want to be able to create forms that work the same as the Order Guide and Catalog Items as stated above. Can I put the Variable Editor on extended Task tables? If so, how (it doesn't appear on the Slush Bucket for fields I can add to the table)? Is there a better way to do this? Any advice would be much appreciated.

1 ACCEPTED SOLUTION

williamsun
Mega Guru

Yes you can.


There are two types of "Formatters" for Variable Editor, one used in Incident and Change, and the one used in Requested item and Catalog Task. (not sure what the difference is)


To make either one available to this new table go to System UI -> Formatters and look for Incident Variable Editor for example, then create an identical one for your custom table.



That should help out.


View solution in original post

7 REPLIES 7

williamsun
Mega Guru

Yes you can.


There are two types of "Formatters" for Variable Editor, one used in Incident and Change, and the one used in Requested item and Catalog Task. (not sure what the difference is)


To make either one available to this new table go to System UI -> Formatters and look for Incident Variable Editor for example, then create an identical one for your custom table.



That should help out.


Thanks William, I'm going to give that a try. Much appreciated


kent_harwell
Giga Contributor

I realize this is a very old post, but I would like to ask for further assistance on this issue. The proposed solution works fine for a custom table, where I am still having difficulty is implementing this for a child task table.

I have 2 custom tables:

One is extended from sm_order and this solution displays the variables on that form as desired.

The other table is extended from sm_task and is being used for tasks related to the first table in a related list (like sc_req_item and sc_task). I can't figure out how to get a variable editor on the child task table to show the variables of the parent record.

I have tried combining the logic in com_glideapp_questionset_default_question_editor and com_glideapp_servicecatalog_veditor but can't get this to work.

Can anyone provide help with this?

 Here is my edited macro based on com_glideapp_servicecatalog_veditor:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:if test="$[current.canRead()]">
    <g:requires name="scripts/js_includes_catalog.js" includes="true"/>
    <g:requires name="styles/${new CatalogCssSelector().getVariableCss()}" includes="true"/>
    <g2:evaluate var="jvar_catalog_item">
       function eval_cat_item() {
          var cat_item = "";
          var className = current.getRecordClassName();
          if (className == "u_treasury_operations") {
             cat_item = current.u_cat_item;
          } else if (className == "u_treasury_operations_tasks") {
             cat_item = current.parent.u_cat_item;
          }
          return cat_item;
       }
       eval_cat_item();
    </g2:evaluate>

    <g2:evaluate var="jvar_cat_sets" jelly="true">
       var jvar_cat_sets = "";
       var gr = new GlideRecord("io_set_item");
       gr.addQuery("sc_cat_item", jelly.jvar_catalog_item);
    gr.addQuery("variable_set.type", "one_to_one");
       gr.query();
       while (gr.next()) {
          if (jvar_cat_sets.length > 0)
             jvar_cat_sets += ",";
          jvar_cat_sets += gr.variable_set;
       }
       jvar_cat_sets;
    </g2:evaluate>

    <j2:if test="$[jvar_catalog_item != '']">
  <div data-sn-macro-sys-id="${jvar_macro_sys_id}">
     <g2:client_script type="catalog_question_editor" catalogItem="$[jvar_catalog_item]"/>
     <g:inline template="catalog_ui_policy.xml" />
     <g2:render_component componentName="com.glideapp.servicecatalog.VEditor"/>
  </div>
    </j2:if>
</j2:if>
</j:jelly>

 

At the moment it just breaks the form and nothing below this in the form layout is displayed

 

Can they be passed from the workflow when adding tasks, like when passing variables to Catalog Tasks on the workflow for a Requested Item?