custom table child tasks: want to bring variables from the parent table to child

chrisn_
Mega Guru

Hello everyone,

I have created a scoped application that the end users wish to add a request functionality to. I have created 2 custom tables, one extended from the sm order table and one from the sm task table. I am using a record producer to create these requests on the custom tables and I am easily able to use the existing sm variable editor to expose the record producers variables on the "request record". What I cannot figure out is how to expose these on the child task table I have created. 

Since I am not using the request application I cannot use the catalog task functionality in my workflow. I must use create task instead. I have created a new variable editor for the table as some of the docs suggest, but it does nothing. I have found a number of older threads that say this cannot be done on a child table  like I am trying to do, but they are a few years old and I was hoping this may have changed. If I cannot use the variable editor could I do this with scripting in the create task function? Any suggestions would be greatly appreciated!

3 REPLIES 3

Michael Jones -
Giga Sage

Well, you might give this a try. I have not had an opportunity to attempt this myself, but it looks promising. 

https://community.servicenow.com/community?id=community_article&sys_id=6117ad69db45e810a08a1ea668961...

Based on some of the comments you would want to make the UI Macro in the global scope, but then define the formatter in the scoped application as otherwise some of the API's will throw errors. 

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

hmm This is very much in the right direction but I must have made a mistake in creating mine. I have created a request style table that I am running a workflow on and I have created a child task table to function like catalog task. I think I have made a mistake while crafting this. I think my failing is that I am working with 2 tables while child incidents are still incidents, not a separate type of record. I am currently aiming the query at my request table, but that might be my error?

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:requires name="scripts/js_includes_catalog.js" includes="true"/>
<g:requires name="styles/${new CatalogCssSelector().getVariableCss()}" includes="true"/>
<g:requires name="scripts/classes/ServiceCatalogForm.js"/>


<g2:evaluate var="jvar_catalog_item">


function eval_cat_item() {


var cat_item = "";


var catItemProducedGr = new GlideRecord("sc_item_produced_record");


catItemProducedGr.addQuery("record_key", current.x_unoci_graduate_d_graduate_division_request);


catItemProducedGr.query();


if (catItemProducedGr.next())


cat_item = catItemProducedGr.getValue("producer");


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.query();


while (gr.next()) {


if (jvar_cat_sets.length > 0)


jvar_cat_sets += ",";


jvar_cat_sets += gr.variable_set;


}


jvar_cat_sets;


</g2:evaluate>

 


<div data-sn-macro-sys-id="${jvar_macro_sys_id}">


<g2:evaluate jelly="true"> var recordObject = new GlideRecord('x_unoci_graduate_d_graduate_division_request');


recordObject.get(current.x_unoci_graduate_d_graduate_division_request);


</g2:evaluate>


<j2:set var="ref" value="recordObject" />


<j:set var="jvar_producer_target_record" value="true"/>


<g2:client_script type="catalog_item" catalogItem="$[jvar_catalog_item]"/>

<g:inline template="catalog_ui_policy.xml"/>

<g2:render_component componentName="com.glideapp.servicecatalog.DefaultQuestionEditor"/>


</div>


</j:jelly>

ANIL Maddha
Tera Contributor

Hello Guys,

 

Above solution/Idea worked for me, Thank you.

 

Did you get a chance to look at the issue related to save/update  variables from task level (Child Task record) . Please suggest any alternative solution to save/update variables from child task record to parent request record.

 

Thanks,

Anil