Fulfiller Mandatory Questions in Catalog Item

kailashthiyagar
Kilo Guru

I have a catalog item and there are 3 variables which will be visible and mandatory after the submit of the request. The person who is going to work on the task, has to fill the values in it .

I m using the below script on load and made it as "Applies on Requested Items/Tasks" and on "Catalog view". The questions appear as mandatory after submit of the request with this script. i m not able to save the RITM without entering any values for these variables. But if i close the task, the RITM is getting closed..

How to handle this scenario

var isAdmin = g_user.hasRole('admin');

  var isCatalogMaster = g_user.hasRole('catalog_master');

  if (isAdmin ||   isCatalogMaster) {

  // alert('Current user is an admin');

  //g_form.setVisible('current_priority', true);

  g_form.setMandatory('quality_standards_outcome', true);

  g_form.setMandatory('performance_standards_outcome', true);

  g_form.setMandatory('security_standards_outcome', true);

  }

  else

  {

  g_form.setMandatory('quality_standards_outcome', false);

  g_form.setMandatory('performance_standards_outcome', false);

  g_form.setMandatory('security_standards_outcome', false);

  }

1 ACCEPTED SOLUTION

Hi Kailash,



There is a column Global, not visible on form.


Add it to the list view and mark these variables global.


They are important on the catalog task, because an engineer would look at task and not the RITM, while fulfilling a request



find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

24 REPLIES 24

In that case, mark all the variables not Global.


And in the catalog task activity in workflow, add the required variables.



find_real_file.png




var filenameArr=[];


  var filenameArrDup=[];


  var filenames=source.u_file_name;


  var valid =[];


  var isExist='';


var id='';


  filenameArr = filenames.split(',');


  //filenameArrDup=filenameArr;


  for(var i=0;i<filenameArr.length;i++){


  var filenameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');


  filenameRec.addQuery('file_name',filenameArr[i]);


  if (!filenameRec.next()){


      filenameRec.file_name=filenameArr[i];


      filenameRec.active='true';


      id = filenameRec.insert();


      valid.push(filenameArr[i]);


  }


  }


  return valid;



Please mark this response as correct or helpful if it assisted you with your question.

Hi sanjivmeher ,


For "Variables" on Task form, one more Like +++



But this one, right, still not working



id = filenameRec.insert();


if(id!='' || id!=null)


      valid.push(filenameArr[i]);



Actually "insert" method shoudl return the unique id of the record being inserted.. So i m checking for the null condition and doing an insert.. but when i debug, i dont see any values for id in the debugger and not able to set any condition.


it should be  



id = filenameRec.insert();


if(id!='' && id!=null)


      valid.push(filenameArr[i]);



Please mark this response as correct or helpful if it assisted you with your question.

sanjivmeher



Sorry to bug u again.. now comes the problem like, so if the



fileNameArr='sn.te,sn1.mac,sn3.xlsm'   in this case, sn1.mac, sn3.xlsm already exist in the table.. and sn.te is not a valid record, so i end up in getting empty value in the variable 'valid'



So i added a else condition but its not going into else part at all even though the record is present



if (!filenameRec.next()){


}


else{


valid.push


}


I am little confuse, with what you are trying to do. But try below



  if (!filenameRec.next()){


      filenameRec.file_name=filenameArr[i];


      filenameRec.active='true';


      id = filenameRec.insert();


      valid.push(filenameArr[i]);


  }


else


{


        valid.push(filenameRec.sys_id);


}



Please mark this response as correct or helpful if it assisted you with your question.