CA Service Management

 View Only
  • 1.  detail_wf panel in CA ServiceDesk - PreSave Trigger

    Posted Aug 12, 2016 05:14 AM

    Hi all,

     

    When raising a change order, users need to fill out a risk assessment.

    The risk assessment populates the field RISK as per below.

    There is a requirement to prevent users from initializing the change order if the risk field is NULL.

     

    So for example....a new change order is raised

    Now the user will go and initialize change

     

     

    The user is now in the detail_wf panel


    In the detail_wf panel, we currently have a function presaveTrigger()

    The preSaveTriger states that

    IF the user chooses reject AND the comment field is NULL

    THEN an alert message will appear.

     

    See context below

     

    function preSaveTrigger()

    {

    try

    {

    var status = document.getElementsByName("SET.status")[0].value;

    if (status == "REJ")

    {

    var comments = document.getElementsByName("SET.comments")[0].value;

    if (comments == "")

    {

    alert("If you reject the change order, please add comment under Task Comments below");

    return false;

    }

     

     

    Using similar logic......my requirement is to have another predefined trigger, but it would need to reference the chg table as well as wf table.

    My required rule would be

    IF chg.risk is NULL then the user cannot save the workflow task. An alert will appear saying "Error - Change Order risk not completed".

     

    Would it be possible to code a preSave trigger in the detail_wf that references data in the chg??

    See below example....I am struggling to reference chg fields in the wf panel.

     

     

    function preSaveTrigger()

    {

    try

    {

    var chg.risk = document.getElementsByName("SET.chg.risk")[0].value;

    if (chg.risk == "")

    alert("Error - Change Order risk not completed");

    return false;

    }



  • 2.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger

    Posted Aug 12, 2016 06:56 AM

    The Risk is not available as a JS variable on the WF page. Try something like this:

    {

    var chg_risk = "$args.chg.risk";

    if (chg_risk == "")

    alert("Error - Change Order risk not completed");

    return false;

    }



  • 3.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger

    Posted Aug 16, 2016 06:08 AM

    Hi Chris,

     

    Thank you very much for the reply and my apologies for the late response.

     

    I've had a chance to look at what you suggested.

    The below code does indeed assist in that it will check if the risk value of the change is NULL and it will throw the error message accordingly

     

    if status == "zyes"

         {

         var chg_risk = "$args.chg.risk";

              if (chg_risk == "")

              {         

              alert("Error - Change Order risk not completed");

              return false;

              }

         }

     

    However, a further requirement is for the category of the change to have a certain survey.

     

    So basically.....If the category does not have a survey, don't throw this message.

     


    Can I drill down this deep?

     

     

     

    So when I modify my code to below. 

    if status == "zyes"

         {

         var chg_risk = "$args.chg.risk";

         var chg_survey = "$args.chg.category.risk_survey.sym";

              if (chg_risk == "") && (chg_survey == "Core Technology Solutions Risk Assessment")

              {         

              alert("Error - Change Order risk not completed");

              return false;

              }

         }

     

    I think the new var of chg_survey is not correct.

    What is the best procedure to drill down to the risk survey sym, using the $args syntax?



  • 4.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger

    Posted Aug 16, 2016 08:28 AM

    It seems that your chg_survey variable is corect. You can always try to add alert(chg_survey) to check the value of the variable



  • 5.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger
    Best Answer

    Posted Aug 16, 2016 10:36 AM

    Hi all,

    So I finally figured this out. Thanks to Chris Mitrana, Gutis and Chris Hackett for all the advise.

     

    My code is as follows.

     

    if (status == "zyes")

           {

         var chg_risk = "$args.chg.risk";

         var chg_cat = "$args.chg.category.risk_survey.id";

         if (chg_cat == "400001" && chg_risk == "")

    //Checks if the risk survey of the category has code of "400001" and checks if risk value is NULL

         {

         alert("The risk assessment has not been completed!"}

         return false;

         }

    }



  • 6.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger

     
    Posted Aug 16, 2016 11:10 AM

    Thanks for sharing the solution!



  • 7.  Re: detail_wf panel in CA ServiceDesk - PreSave Trigger

     
    Posted Aug 15, 2016 07:29 PM

    Hi jwood1 - Did mitu's response help answer your question? If so please mark as Correct Answer. Thanks!