How to write the correct expression for a custom wait step | Community
Skip to main content
Level 2
June 2, 2026
Question

How to write the correct expression for a custom wait step

  • June 2, 2026
  • 3 replies
  • 45 views

The current journey design adopts wait steps after each segment ranging from 30 mins to 4.5 hrs. This unnecessarily uses a wait nodes. I want to simplify the journey/reduce the number of nodes.

 

Therefore, I instead want to replace these wait nodes with a single custom wait step. I have written an expression. The AJO expression editor has validated the syntax (yay!), so it seems I might be on the right track. However, can anyone confirm that this expression is correct? Do I need to include other functions? Or is there a simpler expression I can write?

Note: I am using the event schema to trigger profiles to enter the journey, and each profile that enters is segmented as defined by the triggerDelay attribute defined in the schema construct. I am using this segment to define the number of minutes to wait ranging from 30 minutes to 270 minutes (4.5 hrs).

if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "1") then
(toDateTimeOnly(nowWithDelta(30,"minutes")))
else
(if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "2") then
(toDateTimeOnly(nowWithDelta(90,"minutes")))
else
(if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "3") then
(toDateTimeOnly(nowWithDelta(150,"minutes")))
else
(if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "4") then
(toDateTimeOnly(nowWithDelta(210,"minutes")))
else
(toDateTimeOnly(nowWithDelta(270,"minutes"))))))


Validated Syntax

 

    3 replies

    Level 2
    June 2, 2026

    Another question I thought of after my post. What if I wanted the else statement to instead send immediately i.e. wait 0 minutes, would I simply use the now() function i.e

    else
    (toDateTimeOnly(now()))

    Or would I write 0 minutes using the nowWithDelta function i.e.

    else
    (toDateTimeOnly(nowWithDelta(0,"minutes")))

     

    Level 3
    June 2, 2026

    Hey ​@KeironWratt 

    Your expression seems correct and will work! We had an use-case where we followed a similar approach. However, I’d recommend testing the output via a simple custom action with this endpoint

     

    And to answer your follow-up question, yes, we can simply define the expression as you mentioned for “0” minutes. Refer this documentation for Date related helper functions.

    else(toDateTimeOnly(now()))

     

    Hope this helps!

    Cheers,

    Ganesh Kumar

    Level 2
    June 2, 2026

    Thanks ​@IamCGK, much appreciated. 

    SatheeskannaK
    Community Advisor
    Community Advisor
    June 2, 2026

    @KeironWratt Your expression appears to be correct if your intention is to utilize the custom expression within the one wait activity. Based on the flow, added 0 wait time to the else part on the below expression.

    if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "0") then
    (toDateTimeOnly(nowWithDelta(30,"minutes")))
    else
    (if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "1") then
    (toDateTimeOnly(nowWithDelta(90,"minutes")))
    else
    (if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "2") then
    (toDateTimeOnly(nowWithDelta(150,"minutes")))
    else
    (if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "3") then
    (toDateTimeOnly(nowWithDelta(210,"minutes")))
    else
    (if (@event{DW1267_J1_WBC_Dec_AdvocacyDW1267_J1_WBC_Dec_Advocacy._wbg.customerEventAttributes.nonPiiAttributes.triggerDelay} == "4") then
    (toDateTimeOnly(nowWithDelta(270,"minutes")))
    else
    (toDateTimeOnly(nowWithDelta(0,"minutes"))))))

     

     

    Thanks, Sathees
    Level 2
    June 2, 2026

    Thanks ​@SatheeskannaK much appreciated.