HR Task - Variables

eyal abu hamad
Mega Sage

how Can I show the variables from the HR case in the HR task ?

eyalabuhamad_0-1741873128535.png

and to show them here

eyalabuhamad_1-1741873157534.png

is it possible ?

1 ACCEPTED SOLUTION

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

 First, your code need to be modify slightly, from sn_hr_core_task to sn_hr_core_case.
In case, it's still not work, make sure you create the macro in Global, and allow the restricted access privilege

Screenshot 2025-03-17 at 11.36.54.png

 

Brgs,
Phuong
 

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@eyal abu hamad 

this link will help you, it shows how incident variable editor can be shown on incident_task

You can follow same for HR case and HR task tables

Variable editor on child task(other than catalog task) 

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

unfortunately didn't work

phgdet
Mega Sage

Hi Eyal, 
You seem to want to show Variables on HR Task in the portal. 
You can check table ticket_configuration and see an example of sn_hr_core_case (HR Case table). The tab with type Variable Summarizer is an example showing all variables that have been submitted through the case. 
Btw, I dont really think that you can use this type for HR Task table, but create a new one with Custom type, and create your own Variable Summarizer for HR Task through a widget, then attach it to the new tab configuration.
Check the Variable Summarizer widget for your reference or you can do it your own way:
https://<instance-name>.com/sp_widget.do?sys_id=3e2bcf17b7220010bcd50718ee11a956

Screenshot 2025-03-14 at 10.51.04.png

 

Regards, 

Phuong

can I show in he regualr view ?
I tried to add formatter but It didn't work.
I saw an article that says to create  A ui macro and attach it to formatter. also with no luck

UI MACRO

<?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.parent);


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('sn_hr_core_task');


recordObject.get(current.parent);


</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>

 

ui formatter

eyalabuhamad_0-1742122309505.png