How to use Relative Date

Hi,

I am trying to create a BPM where a reminder email will be sent out to user a day before a Task Start date and 1 after Task Due date. But I am not able to use a relative date. I tried to create a calculated Start date 'today' but the option I am still getting when I try to use the field is the calendar option.

Your help is greatly appreciated.

Parents
  • Hi  ,

    Here is how I would set up the process definition for your use case:

    The process definition uses event-based gateways to process depending on one of three different outcomes before determining whether a notification should be sent:

    1. The task status changes to completed before the desired notification date. In this case the process ends since a notification should not need to be sent.
    2. The task due date changes before the desired notification date. In this case, process requeues the event-based gateway so that the wait timer can be updated based on the new date that was set.
    3. The desired notification date is reached.

    For # 3, the wait timer is configured to be relative to the task start / due date as follows:

    When using wait timers, in this fashion, you will want to ensure you account for a couple issues:

    • If it's possible for tasks to be created without start or due dates (in stock Sugar, neither field is required), then you will want to ensure you are triggering this process only when those fields are populated in a new task or added to an existing task. Otherwise, you may get hung processes that add database cruft that will eventually need to be manually cleaned up.
    • If you anticipate a high volume of tasks utilizing this process and the start and/or due dates are far into the future, you should consider alternative approaches because this will add overhead to processing scheduled BPM events. If you think this scenario is applicable, I can share an alternative solution that eliminates that overhead.

    I hope this helps!

    Chris

  •  Thank you for the sharing. We will be using this on our Sugar Automate so we will be looking into a lot of tasks moving forward. By this, what would be the best approach that you can recommend. Thanks

  • Hi  ,

    The following solution typically applies in scenarios where you expect to have 1000s of records waiting to process. If you don't expect the pending volume to be that large, then the prior solution should be suitable.

    The alternative is to use a calculated field for each date field you want to trigger a notification. The calculation would look like the following for the start date:

    ifElse(
        equal(
            daysUntil(
                $date_start
            ),
            1
        ),
        "Send Notification",
        "Do Not Send Notification"
    )

    And like this for the due date:

    ifElse(
        equal(
            daysUntil(
                $date_due
            ),
            -1
        ),
        "Send Notification",
        "Do Not Send Notification"
    )

    Note: Ideally you would just use the daysUntil() function but there is a bug in SugarBPM start events where you cannot trigger a process on an integer field changing to a negative value. 

    The BPM process would then be set up to trigger when your calculated field changes to a value of 'Send Notification' and process the alert. This means there is no wait event so the records are not stuck in a process queue waiting for the eventual date and they only enter into a process on the exact date of the notification.

    Calculated fields only trigger on record saves, so you need a way for those records to be regularly evaluated on a daily basis. Our plugin, Upsert Calculated Fields, is designed to handle those use cases so that you can trigger BPM logic reliably. If you would like a demo of the plugin, please reach out via our website!

    Chris

Reply
  • Hi  ,

    The following solution typically applies in scenarios where you expect to have 1000s of records waiting to process. If you don't expect the pending volume to be that large, then the prior solution should be suitable.

    The alternative is to use a calculated field for each date field you want to trigger a notification. The calculation would look like the following for the start date:

    ifElse(
        equal(
            daysUntil(
                $date_start
            ),
            1
        ),
        "Send Notification",
        "Do Not Send Notification"
    )

    And like this for the due date:

    ifElse(
        equal(
            daysUntil(
                $date_due
            ),
            -1
        ),
        "Send Notification",
        "Do Not Send Notification"
    )

    Note: Ideally you would just use the daysUntil() function but there is a bug in SugarBPM start events where you cannot trigger a process on an integer field changing to a negative value. 

    The BPM process would then be set up to trigger when your calculated field changes to a value of 'Send Notification' and process the alert. This means there is no wait event so the records are not stuck in a process queue waiting for the eventual date and they only enter into a process on the exact date of the notification.

    Calculated fields only trigger on record saves, so you need a way for those records to be regularly evaluated on a daily basis. Our plugin, Upsert Calculated Fields, is designed to handle those use cases so that you can trigger BPM logic reliably. If you would like a demo of the plugin, please reach out via our website!

    Chris

Children
No Data