Variables display in catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2024 01:25 AM
After submitting the catalog,Variables are displayed in RITM but not on the Catalog task form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2024 01:35 AM
Hi,
Are you using a flow or workflow?
In workflow when you create a task you have to add the variables that should show on the task too. is that done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2024 02:51 AM
Can you please check whether the variable editor is added in task form?
Can you also check whether you have added variables under flow or workflow for that task?
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2024 03:16 AM - edited ‎07-12-2024 03:17 AM
Hi @Dhanush Rao K ,
OOB the mapping between RITM and sc task for variable is not available so as a workaround you can Write a after insert Business Rule on sc task table,
Write the below script in advanced Section,
(function executeRule(current, previous /*null when async*/) {
// this is used for ad hoc tasks that are manually created. This will add all the RITM variables and variable sets to the task.
var variables = []; // array of variable sys_ids to add to the task
var catItem = current.request_item.cat_item.sys_id.toString();
var grVars, ga, gr;
// get individual variables
var grVar = new GlideRecord( 'item_option_new' );
grVar.addQuery( 'cat_item', catItem );
grVar.query();
while ( grVar.next() ) {
variables.push( grVar.sys_id.toString() );
}
// get variables from variable sets
// get m2m for var set to item
var grSet = new GlideRecord( 'io_set_item' );
grSet.addQuery( 'sc_cat_item', catItem );
grSet.query();
while ( grSet.next() ) {
// get variables from each variable set
grVars = new GlideRecord( 'item_option_new' );
grVars.addQuery( 'variable_set', grSet.variable_set.sys_id.toString() );
grVars.query();
while ( grVars.next() ) {
variables.push( grVars.sys_id.toString() );
}
}
// add variable, if it isn't already there
for ( var i = 0; i < variables.length; ++i ) {
// count to see if var exists already
ga = new GlideAggregate( 'sc_item_variables_task' );
ga.addAggregate( 'COUNT' );
ga.addQuery( 'task', current.sys_id.toString() );
ga.addQuery( 'variable', variables[ i ] );
ga.query();
ga.next();
if ( ga.getAggregate( 'COUNT' ) == 0 ) {
// add variable-task record
gr = new GlideRecord( 'sc_item_variables_task' );
gr.initialize();
gr.task = current.sys_id.toString();
gr.variable = variables[ i ];
gr.insert();
}
}
})(current, previous);
tried in Pdi it is working
Reference article
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang