Variable Formatter on the Related Field Instead of the direct target record of Record Producer

Siva
Tera Expert

Hello All, 

 

I have a record producer targetted to entity table,  I have a control record referencing that entity. I was able to display the variable formatter on the entity table seamlessly using the same approach of creating a formatter and a macro and adding it to the form layout of the entity form as we do it in incident variable editor. 

 

But i am not able to identify why its not working in the control table, if  i wanted to add it, i had made necessary changes and here is my code 

 

<?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:if_polaris>
<g:then>
<g:requires name="styles/${new CatalogCssSelector().getPolarisVariableCss()}" includes="true"/>
</g:then>
</g:if_polaris>
<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.getValue('profile'));
catItemProducedGr.query();
gs.info("test:"+catItemProducedGr.getRowCount(),"macrotest");
if (catItemProducedGr.next())
cat_item = catItemProducedGr.getValue("producer");
return cat_item;
}
eval_cat_item();
</g2:evaluate>
<g2:evaluate var="jvar_questionset_read_only" jelly="true">
(gs.getProperty('glide.sc.evaluate.variables.write.access', true) == 'true') ? !current.variables.canWrite() : !current.canWrite();
</g2:evaluate>
<div data-sn-macro-sys-id="${jvar_macro_sys_id}">
<g2:evaluate jelly="true"> var recordObject = new GlideRecord('sn_grc_profile');
recordObject.get(current.profile);
</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>

 

Could some one let me know if there is an issue in this 

 

1 ACCEPTED SOLUTION

Siva
Tera Expert

Hey @Ankur Bawiskar Thanks for taking your time in assisting here. Got it fixed, after creating the Macro in global scope and formatter in the proper target scope with some existing community info as well from other question. The issue is closed now. 
This article did help to some extent in bringing this to resolution if someone is looking for the same in future.

https://www.servicenow.com/community/developer-articles/variable-editor-on-child-task-other-than-cat...

View solution in original post

14 REPLIES 14

Task is empty in the record producer produced records table, its only showing some value in the record key attribute @Ankur Bawiskar which i tried to query in the existing code. 

@Siva 

check if this helps

Variable editor on child task(other than catalog task) 

I was able to achieve this when I created reference field on CHG which points to INC and INC was submitted via record producer

You should be able to achieve as well by small tweak

CHG Form

AnkurBawiskar_2-1739945819842.png

INC Form

AnkurBawiskar_3-1739945831856.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Siva
Tera Expert

Hey @Ankur Bawiskar Thanks for taking your time in assisting here. Got it fixed, after creating the Macro in global scope and formatter in the proper target scope with some existing community info as well from other question. The issue is closed now. 
This article did help to some extent in bringing this to resolution if someone is looking for the same in future.

https://www.servicenow.com/community/developer-articles/variable-editor-on-child-task-other-than-cat...

@Siva 

Glad to know.

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Siva 

Did you accidentally marked your own response as correct?

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader