CA Service Management

Expand all | Collapse all

SDM - Status transition condition

Jump to Best Answer
  • 1.  SDM - Status transition condition

    Posted 11-15-2017 04:21 PM

    Hi everyone,

     

    Is there a way to use a timespan in a condition?  Like if you wanted to prevent a closed ticket from being changed to the open status if the closed date is greater than 30 days in the past? 

     

    Thanks,

    Tammy



  • 2.  Re: SDM - Status transition condition

    Posted 11-15-2017 04:37 PM

    Hi Tammy,

     

    It doesn't look like it's possible to use timespans in site defined conditions.  To solve this use case I've used a bit of javascript to conditionally remove statuses from the drop down.

     

    I know your site doesn't like customization, so that may not work for you.  However, if that's changed let me know and I'll help you with it.

     

    Example:

    Is it possible to hide reopen status from drop down in request order detail page if request order is older more than 60 days in CA Service Desk 12.9? 



  • 3.  Re: SDM - Status transition condition

    Posted 11-15-2017 08:01 PM

    Thanks, Grant.  You're right, we don't like to do customizations unless it's something absolutely necessary -- and thank you for the link and the offer to help!  --- But is this just code that gets added to the forms?  If it is, I thought those were considered 'adaptations', not customizations...

     

    Thanks,

    Tammy



  • 4.  Re: SDM - Status transition condition

    Posted 11-15-2017 08:09 PM

    Hi Tammy,

     

    That’s right, this code lives on the htmpl file. However, since it’s JavaScript added via the source tab it’s not supported by CA. That’s at least what I’ve heard in the past, not sure if its changed.



  • 5.  Re: SDM - Status transition condition

    Posted 11-16-2017 08:36 AM

    Hi Grant/Tammy,

    CA Support doesnt specifically support or assist with direct code customizations out side of the design tab in WSP, however, thats not to say it cannot be done or should not be done - but more of just the fact that you as a customer are responsible to maintain that customization going forward through patches and upgrades.  With the new Customization Upgrade Utility, its much easier to do that, so its not as much of an issue as it used to be.

    Hope this helps clear things up a bit

    Thanks,

    Jon



  • 6.  Re: SDM - Status transition condition

    Posted 11-16-2017 10:19 AM

    Thank you Jon, that clears it up a bit.  It's also good to hear the Customization Upgrade Utility makes upgrading easier!  When we upgraded to v17 I still went through each file one by one instead of using the new utility, maybe I should have given it a try.

     

    tzadell, this code should solve your use case.  This example is for the detail_in form, to use it on detail_cr or detail_pr change the factory on the status macro to their factory code (crs_cr, crs_pr).  I've also added a check for the access type onto the if condition, that way administrators can still re-open tickets.

     

    //Conditionally set status to read-only if the ticket was closed more than 30 days ago
    var zNow = Number(Math.round(new Date().getTime() / 1000));
    var zClose_Date = Number("$args.close_date_INT_DATE");
    console.log("Close Date: " + zClose_Date + "\nNow: " + zNow + "\nClose Date plus 30 days <= Now: " + ((zClose_Date + 2592000) <= zNow));
    if((zClose_Date + 2592000) <= zNow && "$args.status" == "CL" && "$cst.access_type.sym" != "Administration"){
    <PDM_MACRO name=dtlReadonly hdr="Status" attr=status>
    }
    else{
    <PDM_MACRO name=dtlDropdown hdr="Status" attr=status factory=crs_in>
    }


  • 7.  Re: SDM - Status transition condition

    Posted 11-16-2017 12:15 PM

    Thanks so much, Grant!  This looks wonderful... I can't wait to try it out.  Does it matter where in the code I insert this?  Also, you said your example was for the incident form, but the factory in your example shows 'crs_cr' --- is the example really for the request form, and the factory for incidents is 'crs_in'?


    Thanks,

    Tammy



  • 8.  Re: SDM - Status transition condition
    Best Answer

    Posted 11-16-2017 01:04 PM

    Hi Tammy,

     

    Yes, sorry for not including the implementation steps.  It does matter where you put the code.  Follow the steps below to implement this.

     

    1. Open WSP then find the detail_in form (there may be more than one depending on how you have your roles configured)

    2. Switch to the source tab

    3. Find the following line

    <PDM_MACRO name=dtlDropdown hdr="Status" attr=status factory=crs_in>

    4. Replace it with this code

    //Conditionally set status to read-only if the ticket was closed more than 30 days ago
    var zNow = Number(Math.round(new Date().getTime() / 1000));
    var zClose_Date = Number("$args.close_date_INT_DATE");
    console.log("Close Date: " + zClose_Date + "\nNow: " + zNow + "\nClose Date plus 30 days <= Now: " + ((zClose_Date + 2592000) <= zNow));
    if((zClose_Date + 2592000) <= zNow && "$args.status" == "CL" && "$cst.access_type.sym" != "Administration"){
    <PDM_MACRO name=dtlReadonly hdr="Status" attr=status>
    }
    else{
    <PDM_MACRO name=dtlDropdown hdr="Status" attr=status factory=crs_in>
    }

    5. Save and Publish



  • 9.  Re: SDM - Status transition condition

    Posted 11-16-2017 06:20 PM

    Thanks, Grant.  So was I right that your example has the factory for requests, not incidents?  'crs_cr' 

     

    'crs_cr' would be for requests, and 'crs_in' would be for incidents, right?

    Thanks.

    Tammy



  • 10.  Re: SDM - Status transition condition

    Posted 11-16-2017 06:25 PM

    Yes..  Good catch, I updated my example.



  • 11.  Re: SDM - Status transition condition

    Posted 11-16-2017 06:41 PM

    Great, thanks.... Just wanted to confirm what I was thinking!

     

    Tammy



  • 12.  Re: SDM - Status transition condition

    Posted 11-20-2017 06:20 PM

    I haven't had time to try this out yet, but will post results once I have...

     

    Thanks again, Grant! 

    Tammy



  • 13.  Re: SDM - Status transition condition

    Posted 11-16-2017 12:10 PM

    Thanks, Jon!