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

vams1
Tera Contributor

Hi @Siva,

My observation is its Seems like the issue in your code was the use of incorrect namespace prefixes(xmlns:j2="jelly:core" xmlns:g2="glide"). This could prevent the Jelly script from functioning as intended. Correcting these prefixes ensures that the Jelly script can properly interpret and execute your code.


Thanks -Vamsi G

@vams1 Thanks, tried but it didn't work

Ankur Bawiskar
Tera Patron
Tera Patron

@Siva 

But why to show on Control table? the variables are associated with Entity record and not Control

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

@Ankur  The review process happens by teams on the control and it would be handy for them to have the information of the variables loaded onto the control. They can still look from the reference icon of the entity field on the top. But looking to see if we can provide the formatter on to the control form directly