5 Replies · Latest reply on Sep 13, 2017 11:24 AM by Debashree Pati

    How to implement an onCellEdit script that puts up a confirm message and removes mandatory requirements

      Hi All,

       

      I have a OnChange script that pops up a confirm message when the State field on a Change Request form is set to 'Closed Cancelled'. If user confirms cancellation the it also sets the mandatory requirements on few of the fields to false. The code is as below:

       

      function onChange(control, oldValue, newValue, isLoading, isTemplate) {

          if (isLoading || newValue === '') {

            return;

          }

         //Type appropriate comment here, and begin script below

         if (newValue == 50){  // closed_cancelled value is 50

         var answer = confirm("Cancelling this Change will cancel it's underlying open tasks, workflow, and approvals. Are you sure you want to cancel this Change Request?");

         if (answer == false) {

             return false;  //Abort submission

         }

         g_form.setMandatory('assignment_group', false);

         g_form.setMandatory('start_date', false);

         g_form.setMandatory('company', false);

         g_form.submit();

         }

      }

       

      How can I achieve the above in an onCellEdit script so that when in list view if the State field of one or more Change requests is set to 'Closed Cancelled', there will be a confirm message followed by the removal of mandatory requirements on few fields if user confirms cancellation?

       

      Thanks,

      Debashree