Adding multiple restrictions on a datetime field

Version 5

    How to:

    Allow users to request for temprorary access to a service.

    Since the access is temprorary we need to specify the maximum duration. Additionally since the input will be done by the end user, we want the end date entry to be after the start date to avoid bad data.

    1. Create the Attributes

    First we need to crate 4 datetime Attributes.

    Start Date
    End Date
    Max Date
    End DateCopy

    Do not make any selections on the Persistance Type window that will appear, just press OK

    Persistence Type.png


    From Object Designer, browse to Max Date and from the properties panel add the bellow Before Save calculation that will controll the duration (X amount of days)

    import System
    static def GetAttributeValue(Request):
        Duration = Request._StartDate.AddDays(60)
        return Duration

    The dependency is the Start Date.




    2. Configure the Attribute Properties

    Go to Window Manager and add the attributes on your window. The attribute properties that you need to modify are shown bellow.


    Start Date - Is calculate on change ( True)


    End Date Copy - Date time Range Operator ( Before )
    Date time Range Attribute ( Max Date)


    End Date - Date time Range Operator ( After)
    Date time Range Attribute ( Start Date)

    Rename the "End Date Copy" label to "End Date" (1) and hide the "End Date Attribute" and it's label (2) by setting "Show On Window" to False



    3. Create a copy rule

    From Window Manager, select your Object and click on Business Object Copy Rules. Expand the tree untill you reach your business object. Right click on it and select New Rule.


    Event: Initialise,Create,Update,Value Changed
    Target: End Date
    Sources: _End DateCopy


    Tick "Always execute rule" and select Overwrite as your Policy.

    Copy Rule.png


    4. Result