Previous Topic

Next Topic

Book Contents

Book Index

Passing Information Between Events

Navigator > Setup > Company > Scripts > Script Events

You can use Property Values to pass information between script events, such as between a BeforeSave script and an AfterSave script. This can be used for Accredo Forms or Data Objects.

Use SetPropertyValue to create user defined variables or objects. SetPropertyValue and GetPropertyValue methods can be used to pass information without having to use public variables.

Once the object or form is closed, property values are removed, so there are no issues with public variables persisting with unknown values or states.

SetPropertyValue

method SetPropertyValue(PropertyName: String, Value: Variant)

This sets the value of a property or MaxBasic variable named in PropertyName to the Value. For example:

    datOESalesOrder.SetPropertyValue("SaveStartTime",Time)

will create a property SaveStartTime for the datOESalesOrder object, set to the current time.

GetPropertyValue

method GetPropertyValue(PropertyName: String): Variant

GetPropertyValue method returns the value of the property or MaxBasic variable named in PropertyName. For example:

    datOESalesOrder.GetPropertyValue("SaveStartTime")

will return the value of the property SaveStartTime.

BeforeSave / AfterSave Example

In the following example, a SaveStartTime property can be created to calculate how long a save event takes.

An OE Sales Order BeforeSave script could contain the following:

    Dim datOESalesOrder as Object
    datOESalesOrder = GetTriggerObject
    If not IsNull(datOESalesOrder) and datOESalesOrder.ClassName = "OEOrderData" and datOESalesOrder.WasInserting then
      datOESalesOrder.SetPropertyValue("SaveStartTime",Time)
    End if

The OE Sales Order AfterSave script could then access this property and calculate the time taken with the code:

    Dim datOESalesOrder as Object
    datOESalesOrder = GetTriggerObject
    SaveEndTime = Time
    TimeTaken = SaveEndTime - datOESalesOrder.GetPropertyValue("SaveStartTime")