3 Replies Latest reply on Jul 26, 2017 11:09 PM by Senta

    Calculations from multiple business objects

    blwallace Apprentice

      Is there a way within a calculation to get the value from another business object?  Calculations start with:

      import System
      static def GetAttributeValue(dataObject)
      

      I'm a bit fuzzy on the meaning of GetAttributeValue(dataObject).  Does this mean all attributes available to the calculation are strictly from the dataObject business object?  Can another object's values be polled within any given calculation, or just the one business object?

       

      Thanks,

        • 1. Re: Calculations from multiple business objects
          Senta SupportEmployee

          Hello blwallace

           

          You can accomplish this with the GetObjectByAttribute Function.

          e.g. Incident.GetObjectByAttribute("System.User", "Name", "JSmith1")

           

          See Calculation Writing Tutorial - 8.  Working with Dropdown Lists (Objects)

           

          Regards

          Ivanti Support

          • 2. Re: Calculations from multiple business objects
            blwallace Apprentice

            Senta,

             

            Thank you for the reply.  Function GetObjectByAttribute requires a value of the attribute and I'm unsure what value I have.

             

            What I'm trying to do is on an opening window, have a date field that the analyst fills in as a proposed date - propDate.  propDate is an attribute from a Change object.  Later in the process, I present another window to the analyst to put in the approved date - appDate.  appDate is an attribute from an Approval object.  On this later window I want the propDate value to be there, but allow the analyst to change it, if desired, and if changed appDate != propDate.  I then want to reconcile these dates, meaning I want appDate to update the propDate value in the Change object.  I've conceived of a third date, calcDate in the Change object to be able to allow the reconciliation.  However, I don't know how to make the calculations. 

            1. initially propDate is set by analyst on Change window
            2. appDate is set to propDate (calculated)
            3. appDate gets changed by analyst on Approval window
            4. calcDate is set to appDate (calculated) on Change window (probably a "not shown on window" field)
            5. if calcDate != propDate, calculation changes propDate value to calcDate on Change window

            The reason for calcDate is because my first attempt failed.  I made Change a collection of Approval so I could use the propDate from Change in the Approval window.  This only made the field in Approval Read-Only with no value; which I understand from support is the way something like that would work.  I can't use an attribute from another object like that.  So it was suggested I use calculations and have three different fields.  One on Approval and two on Change.  The first date attribute on change sets the original, proposed date, the second date attribute on change gets the value from the Approval date and compares/modifies the first date attribute.

             

            All that said, I'm not sure how to the get value from the date objects using GetObjectByAttribute function.

            • 3. Re: Calculations from multiple business objects
              Senta SupportEmployee

              Hello blwallace,

               

              as you initial question suggested that you do not hold any references between your =dataObject= and the Change or approval Object (in this case you could have just used the reference to get access to their referenced objects), I suggested GetObjectByAttribute.

               

              So how do you know which Change and which Approval is linked to your =dataObject= ?

               

              Regards

              Ivanti Support