unable to update short description(readonly field) in catalog task

sayan3
Tera Contributor

Hello everyone,
I am facing an issue that is based on catalog task variable (yes/no type) we need to update catalog task short description which is a read only field.

Note: using catalog task activity in workflow we able to get short description's update based on catalog form value.
But here user needs to update catalog task variable from back end and based on that, short description needs to be updated.
below is the code, using this code once we change field value yes to no or no to yes, we able to see short description is updated but once we click on save button value is not saved.


function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
else{
var ga = new GlideAjax('getID');
ga.addParam('sysparm_name', 'getSysId');
ga.addParam('sysparm_sys_property_name', 'sys_id');
ga.getXML(managerFunc);
function managerFunc(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var Unique_Value=g_form.getParameter("sysparm_id");

if (Unique_Value== answer){

if (g_form.getValue('check_this')=='Yes'){

g_form.setReadOnly('short_description',false);
g_form.setValue('short_description','xyz');
}
else{
alert('ghosh1');
g_form.setReadOnly('short_description',false);
g_form.setValue('short_description','abc');
}
}
}
//Type appropriate comment here, and begin script below
}
}

Any help would be highly appreciated

Thanks,
Sayan Ghosh

2 REPLIES 2

Musab Rasheed
Tera Sage
Tera Sage

Hello Sayan,

You must write onload script as well based on 'check_this' field then value will be retained on load as well. Mark my answer as correct or hit like based on impact.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

Community Alums
Not applicable

Hi @Musab Rasheed 

 

sorry for the above script,

 

its the wrong code that wrongly copied above. 

 

please refer the below BR that currently working for order guides. 

(function executeRule(current, previous) {
 
//check if Order Guide or not
var shortDescription = '';
var description = 'Request For: ';
 
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('request', current.sys_id);
grRITM.query();
var count = grRITM.getRowCount();
 
if(count==0)
{
return;
}
 
 
 
if(count == 1 )
{
//If it is not an Order Guide Return from this business rule
grRITM.next();
 
if(grRITM.getValue('order_guide') == null)
{
return;
}
else
{
//OrderGuide with only 1 RITM
shortDescription = grRITM.getDisplayValue('order_guide');
description += '\n' + grRITM.cat_item.name;
current.short_description = shortDescription;
current.description = description;
 
 
}
 
}
 
else
{
 
 
while(grRITM.next())
{
if(shortDescription == '')
{
shortDescription = grRITM.getDisplayValue('order_guide');
}
 
description += '\n' + grRITM.cat_item.name ;
 
}
current.short_description = shortDescription;
current.description = description;
 
}
})(current, previous);
 
 
can you suggest us to make the make the change that to work for the one particular catalog. 
 
Thanks.