CA Service Management

  • 1.  Get Approved/Rejected on submit

    Posted Sep 13, 2016 01:23 AM

    Hi

    I have a custom two step approval process. Once the 1st level has reviewed the request they can of course Approve or Reject. To approve they need to select a user from a lookup field which gets populated automatically from a report data object. I've had to make this field required so that the user doesn't submit without selecting an approver. This doesn't work however if the approver rejects the request as the lookup is required.

     

    I thought of removing the required attribute and rather onSubmit using some javascript to check if the lookup is an empty string. If the string is empty and the status is approved it will alert with the appropriate message. How can I look for and retrieve the 'Approved' status onSubmit? Has anyone does this or something similar?



  • 2.  Re: Get Approved/Rejected on submit
    Best Answer

    Posted Sep 13, 2016 07:33 AM

    I've managed to resolve it. I used the following javascript code:

    checkL2Approver : function() {

       if (_.serviceoption.status() == 507) {

          document.querySelector("select").focus();

          var num = document.activeElement.id;

          var e = document.getElementById(num);

          var strUser = e.options[e.selectedIndex].text;

          var currentValue = ca_fdGetTextFieldValue('form1','l2managerfull');

          if (currentValue == "" && strUser == 'Approved') {

             alert('Please select an approver');

             return false; }

          }

       return true;

      },

     

    On my form at the approval stages the 1st 'select' element is always the one I'm looking for. I set the focus to it and extract the id which is generated dynamically with an incrementing number.