Clarity Service Management

Expand all | Collapse all

Use $args in compound statement?

Jump to Best Answer
  • 1.  Use $args in compound statement?

    Posted 05-03-2016 02:42 PM

    Hola!  We need to make certain fields required when 2 conditions are met. I've never worked with the $args, and cannot find an example of it being used in a compound statement.  I tried building one, but am getting an error. Would appreciate any input.  Thanks!

     

    Desired Outcome: A change order field (on chg table) is only required when change status = pending change manager AND change risk level < 4. The field is located on one of the Tabs.

     

    Idea: Use $args IF/ELSE statement on xx_candp_tab.htmpl form (tried with and without the parenthesis)

     

    without parenthesis

    <PDM_IF "$args.status" == "Pending Change Manager" and "$args.risk.enum" < "4">
    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">
    <PDM_ELSE>
    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">
    </PDM_IF>

     

    with parenthesis


    <PDM_IF ("$args.status" == "Pending Change Manager" and "$args.risk.enum" < "4")>
    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">
    <PDM_ELSE>
    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">
    </PDM_IF>

     

    both variations receive same error


    AHD04407:CA Service Desk Manager html generation error. Could not find or process 'detail_chg_ro.htmpl'.

    AHD04727:Unclosed PDM_IF at xx_candp_tab.htmpl[84]



  • 2.  Re: Use $args in compound statement?

    Posted 05-03-2016 03:26 PM

    Hello,

     

    You need to use javascript operators.  && for AND, || for OR.  This website defines each operator and how to use them, http://www.w3schools.com/js/js_comparisons.asp

    Additionally use the codes for each status in if statements instead of their names. So it should be "PCM" or whatever you set the code too.



  • 3.  Re: Use $args in compound statement?

    Posted 05-03-2016 05:29 PM

    Hi Grant, I updated both the operator & the sym to the code, but it still doesn't work - I get the exact same error whether or not I use the parenthesis

     

    <PDM_IF ("$args.status" == "PndChgMgr" && "$args.risk.enum" < "4")>

    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">

    <PDM_ELSE>

    <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">

    </PDM_IF>



  • 4.  Re: Use $args in compound statement?

    Posted 05-03-2016 05:46 PM

    Do you still get the same error?  You may have inadvertently removed part of an original IF statement.  I've seen this same error message before when I accidentally removed a </PDM_IF>.  I suggest making sure all the PDM_IF statements are closed correctly, it may be easier starting over with a fresh form and inserting your code where desired.



  • 5.  Re: Use $args in compound statement?

    Posted 05-03-2016 06:39 PM

    it's the 'dot-walking'...it didn't like the 'risk.enum', so I updated to just 'risk'. I tried testing each part of the statement separately & have interesting results, one of which is a bit mystifying (maybe I'm just tired).

     

    Status = Pending Change Manager results: the field is required upon editing while IN this status, but not transitioning into the status.  So back to drawing board on this one.

         <PDM_IF "$args.status" == "PndChgMgr">

         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">

         <PDM_ELSE>

         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">

         </PDM_IF>

     

    Risk != 4-Low results: for some reason this is requiring the field for ALL risks, when it should not be requiring for risk4? This is the mystifying part...
         <PDM_IF "$args.risk" != "4-Low">
         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">
         <PDM_ELSE>
         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">
         </PDM_IF>



  • 6.  Re: Use $args in compound statement?

    Posted 05-05-2016 11:30 AM

    Have you resolved this?

     

    If you're trying to make the field required when the pdm_if statement returns "true" (the risk = 4).  I'm not sure you need the quotes, since the value is numeric.

    You could try:

         <PDM_IF "$args.risk" == "4">

         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date" make_required="yes">

         <PDM_ELSE>

         <PDM_MACRO name=dtlDate hdr="Readiness Review Date" attr="zRReview_date">

         </PDM_IF>

     

     



  • 7.  Re: Use $args in compound statement?

    Posted 05-09-2016 03:51 PM

    Not yet - I want the fields to be required upon transitioning into the status or transitioning into the risk, not just when IN the status or IN the risk. For that I don't know if I can still use the htmpl form?



  • 8.  Re: Use $args in compound statement?

    Posted 05-09-2016 05:08 PM
    Hi to have this functionality in transition you need to use trigger and spel code.




  • 9.  Re: Use $args in compound statement?

    Posted 05-09-2016 06:17 PM

    Found someone's old code & am trying to modify - the spel_srvr won't start, so I know it doesn't like something here.  I think the issue is in the .mod file

    .spl file:

    chg::zcheck_chgstatus(...)
    {
    string Method;
    string errmsg;
    Method ="zcheck_chgstatus";

    if (risk < 4 && status == 'PndChgMgr')
    {
      if ( (is_null(zRReview_date)) || (is_empty(zRReview_date)) )
      {
      set_error(1);
      errmsg=format("Please enter Readiness Review Date before updating status to Pending Change Manager");
      set_return_data(errmsg);
      }
     
      if ( (is_null(z4EPQA_by)) || (is_empty(z4EPQA_by)) )
      {
      set_error(1);
      errmsg=format("Please select 4 Eyes Principle Sign-Off By before updating status to Pending Change Manager");
      set_return_data(errmsg);
      }
     
      if ( (is_null(z4EPQA_date)) || (is_empty(z4EPQA_date)) )
      {
      set_error(1);
      errmsg=format("Please enter 4 Eyes Principle Sign-Off Date before updating status to Pending Change Manager");
      set_return_data(errmsg);
      }
    }

     

    .mod file - Note - I cannot figure out what the number '106' is for, it was used for status elsewhere, but not sure what number to use for risk???

     

    MODIFY chg {POST_VALIDATE zcheck_chgstatus(status) 106;};

    MODIFY chg {POST_VALIDATE zcheck_chgstatus(risk) 106;};



  • 10.  Re: Use $args in compound statement?
    Best Answer

    Posted 05-10-2016 12:47 AM

    POST_VALIDATE  zcheck_chgstatus() 4013 FILTER( status{} || risk{});

     

    This one should also work and filter all unnecessary events

     

    POST_VALIDATE  zcheck_chgstatus() 4013 FILTER( status{->'PndChgMgr'} || risk{} && risk < 4);



  • 11.  Re: Use $args in compound statement?

    Posted 05-10-2016 04:43 PM

    that 1st statement works when transitioning into the status based on risk, thank you!!!!!!!!!!!!!!!!  Here's the entirety from the mod file.  I used the 106 since that was being used previously in a statement I removed, so I know it's a good #.

     

    MODIFY chg {POST_VALIDATE  zcheck_chgstatus() 106 FILTER( status{} || risk{});};



  • 12.  Re: Use $args in compound statement?

    Posted 05-10-2016 04:50 PM

    I would suggest You to use

    MODIFY chg {POST_VALIDATE  zcheck_chgstatus() 106 FILTER( status{->'PndChgMgr'} || risk{});};

    Since this will fire only on change to particular status or risk update. As You know status update may happen quite often use of such trigger will be better from performance point of view.



  • 13.  Re: Use $args in compound statement?

    Posted 05-10-2016 08:26 PM

    using your 2nd command w/ the Risk < 4 - I think that refines it the best.  Thanks again for all your help!



  • 14.  Re: Use $args in compound statement?

    Posted 05-10-2016 12:50 AM

    106 is execution sequence for the trigger, each trigger should have unique sequence number, it will give you an warning if two or more triggers have the same sequence number



  • 15.  Re: Use $args in compound statement?

    Posted 05-10-2016 12:26 PM

    Thanks 'gutis' - what is a good method for selecting the trigger numbers? Is there a way to see how many or is it just by trial & error, augmenting # as you go?



  • 16.  Re: Use $args in compound statement?

    Posted 05-10-2016 03:01 PM

    I always use over 4000 and only uneven numbers, sometimes you need to fire before some Default trigger but that is on very rare occasions.