Skip navigation
1820 Views 6 Replies Latest reply: Jan 18, 2012 9:55 AM by Stu McNeill RSS
keithr Specialist 136 posts since
Apr 27, 2009

Has received 3 of 9 achievements.
Currently Being Moderated

Jan 6, 2012 12:13 AM

Using Calculations to copy dates from one process to another

When creating a change from within a service request, I would like the ability to copy the “implementation date” specified on the request to the change request.

 

Have tried this using the following calculation:

 

import System

static def GetAttributeValue(Change):

Value = Change.RequestChanges.Incident._TargetDate

return Value

 

The Calculation has been added to the Change.Target date on the automatic “create change” action within the request process but the copy does not initiate.

 

The attribute is a date attribute and is not selectable if I try to use Value Types as you might with a string.  If anyone has successfully copied a date from one process to another, would appreciate knowing how this was achieved.

  • Stu McNeill SupportEmployee 1,072 posts since
    Nov 11, 2008

    Has received 7 of 9 achievements.

    Hi Keith,

     

    This actually came up yesterday in another thread and should give you the answer: Value Types & Dates

  • Stu McNeill SupportEmployee 1,072 posts since
    Nov 11, 2008

    Has received 7 of 9 achievements.

    Hi Keith,

     

    The important point of the other thread is that you can't just reference the collection, you need to use a For loop to get the attached Incident.  In your case IncidentChanges is a collection that could have multiple Incidents attached.  You need to decide which incident you want to get the Date from.  If there will only every be one incident attached you can just do the same trick I suggested in the other thread of looping through and setting the incident to a variable.

     

    I hope that helps.

  • SDESK Apprentice 54 posts since
    Mar 6, 2009

    Has received 1 of 9 achievements.

    Thanks Stu,

     

    I have had a play with the loop calculation but ran into some errors.  Can you tell me what "ParentLink" relates to in your post.  I am presuming "Parent" in my case would be "IncidentChanges" but just not sure what to substitue "ParentLink" for:

     

    Example from previous post:

    Parent = null
         for ParentLink in Request.Parents:
              Parent = ParentLink.Parent

     

         if Parent == null: return null
         else: return Parent._UserStartDate

  • Stu McNeill SupportEmployee 1,072 posts since
    Nov 11, 2008

    Has received 7 of 9 achievements.

    Hi,

     

    I was planning on writing a full document explaining loop techniques but haven't had a chance yet.  Your latest calculation looks like it should work so it depends what error you're getting as to what the problem is now.

     

    Basically "ParentLink" is just a name you give for when you reference each item in the loop.  You can call it whatever you want:

     

    for Stu in Incident.Notes:

         Value = Stu.Title

     

    In my case I called it ParentLink because each item in the Parents collection is the linking object record so it seemed a sensible name.

  • Stu McNeill SupportEmployee 1,072 posts since
    Nov 11, 2008

    Has received 7 of 9 achievements.

    Sorry I just realised the calculation you put into your last post wasn't what you're trying to use.

     

    In your case you don't need to rename ParentLink but you could call it "ChangeLink" or something similar so it makes more sense, then within the loop where I reference "ParentLink.Parent" you'd change the ".Parent" to ".Change" or ".Incident" to get to the record on the other end of the link.

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 20 points
  • Helpful Answers - 10 points
LANDESK Community powered by Jive SBS® 4.5.7.1  |  Legal Notices  |  Privacy Policy  |  Icon 

TweeterOn Twitter  |  Icon FacebookOn Facebook © 2007 LANDESK Software