7 Replies Latest reply on Jan 10, 2012 7:36 AM by Bricktop

    Value Types & Dates

    gramsay Specialist

      There isn't an option to set a date during a process with a value type.

      How can a date be transferred from one object to another during a process?

      Is this possible?

        • 1. Re: Value Types & Dates
          aparker Employee

          Hi Graham,

           

          I thought I'd answered this by email, so just be sure...

           

          You can only really do this in 7.3.x of LDSD and to do it, you need to use calculations rather than Value Type in the prrocess design.

           

          Andy

          • 2. Re: Value Types & Dates
            Expert

            Hi

             

            I have an issue with this (v7.4), in what I thought was just a simple calculation doesn't seem to be working.  Turning trace logging on isn't picking up anything either.

             

            In the Request Management module, I have a new starter process, for new staff.  There is a "Start Date" attribute for when the new staff member is starting.  This parent request generates various other child requests, and so I wish to pass the "Start Date" attribute to the child requests as this is essentially when a request needs to be completed by.

             

            My calculation looks like this (and it does have appropriate spacing, although it may not show here):

            import System

            static def GetAttributeValue(Request):

            Value = Request.Parents.Parent._UserStartDate

            return Value

             

            I assume I have overlooked something simple here, but for the life of me I can't see what.  Perhaps it is still too early in the year to be at work...

             

            Thanks

             

            Paul

             

            P.S.  As an aside, why is it that date/time fields can't have Value Types set like other attributes?  I see there is already an ER for this - http://community.landesk.com/support/ideas/2356

            • 3. Re: Value Types & Dates
              Stu McNeill Employee

              Paul,

               

              You're correct that you should be able to get past the Value Type limitation via a calculation.  I see you've already found the ER to rectify this

               

              Your calculation is failing because it is trying to directly call the parent, but "Parents" is a collection so you need to always imagine there could be multiple items.  You can't use Parents.Latest() in this case but this simple loop will do what you need:

               

               

                   Parent = null
                   for ParentLink in Request.Parents:
                        Parent = ParentLink.Parent
              
                   if Parent == null: return null
                   else: return Parent._UserStartDate
              
              • 4. Re: Value Types & Dates
                Expert

                Thanks for this Stu - works like a charm.

                • 5. Re: Value Types & Dates
                  Apprentice

                  I'm rubbish at BOO! I don't suppose you have the whole code, I can replace the attribute to match what I have.

                   

                  Much appreciated

                  • 6. Re: Value Types & Dates
                    Stu McNeill Employee

                    Hi Bricktop,

                     

                    The example above is the whole calculation (minus the two lines you always get at the top).  In your case you'd just need to replace _UserStartDate with the name of your DateTime attribute.

                     

                    Hope that helps.

                    • 7. Re: Value Types & Dates
                      Apprentice

                      Hi Stu,

                       

                      I must have had an extra space somewhere as I was getting a couple of syntax errors. Just retried it and it seems to be happy. Many thanks for your fast response.