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

its my mistake sanjivmeher .. let me explain.. the below part of the code is sufficient.. Hw to modify it?



our input   : 'sn.te,sn1.mac,sn3.xlsm'



sn1.mac and sn3.xlsm are already available in the table. so when we try to insert them, we will get error(due to unique key) and in this case id will be null. Hence that value wont be seen in the "List"



Ideally what i want to see in the List is, sn1.mac and sn3.xlsm.. These are the two valid entries.. sn.te will not get inserted into the reference table due to the business rule.. and it shouldnt be displayed on the form "List" as well.




if (!filenameRec.next()){


      filenameRec.file_name=filenameArr[i];


      filenameRec.active='true';


      id = filenameRec.insert();


      valid.push(filenameArr[i]);


  }


if input   : 'sn.te,sn1.mac,sn3.xlsm', but sn1.mac,sn3.xlsm exists.


Then the below code insert a record for sn.te.



if (!filenameRec.next()){ // We are checking here, if recoed doesn't exists


      filenameRec.file_name=filenameArr[i];


      filenameRec.active='true';


      id = filenameRec.insert();


      valid.push(filenameArr[i]); // valid will have sn.te


  }



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

sanjivmeher



yes u r rit.. if i add a "if" condition, i m not getting sn1.mac and sn3.xlsm as well... These are valid values which r present in the table but they fail to get inserted due to duplicate entry.. that shouldnt prevent them from getting added to "valid"



What we can do now?


So if you want them get added to Valid.



if (!filenameRec.next()){ // We are checking here, if recoed doesn't exists


      filenameRec.file_name=filenameArr[i];


      filenameRec.active='true';


      id = filenameRec.insert();


      //valid.push(filenameArr[i]); // valid will have sn.te - Comment this


  }


else


{


          valid.push(filenameArr[i]); // Add values which already exists to Valid variable


}



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

yes sanjivmeher. It worked. Actually yesterday in the code, we missed the query part. Hence it was not going into "else" condition at all.. now it worked.. Thanks.



var filenameRec=new GlideRecord('x_opt_macro_govern_macro_file_names');


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


//filenameRec.query()


  if (!filenameRec.next()){