Check if Date retrieved from CRM is within 2 months

Genesys Cloud CX

I am using a data action in an Architect flow to lookup a contract renewal date in CRM and check if it is due within 2 months from today's date or even a count of 60 days from now. If YES then route the call to a different queue.

The extra challenge i have is the data format in CRM is DD/MM/YYYY but Genesys Cloud CX uses MM/DD/YYYY so some translation maybe required.

Hi Simon,

It is typically possible to use the Java string methods to get out the substring that you want:

Specifically you may want to use a substring method like this one:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html#substring(int,int)

If you continue to have trouble with this, please post an export of your in-progress data action along with an example of the response from your web service so that it is possible to reproduce the issue you are having. Since this is a public forum you will want to replace anything sensitive in either with example data.

--Jason

Thanks for the up-date Jason. Upon testing it seems the database itself in CRM stores the date in YYYY-MM-DD format (e.g from GC data action = 2024-01-15T00:00:00Z) which is different to the displayed date shown in our CRM browsers. This will hopefully make things easier for me. The DateTimeDiff command looks promising too.

Hi @Simon_McKenzie ,

I wasn't sure but is the string "2024-01-15T00:00:00Z" being returned to the flow? If so, that's an ISO 8601 formatted date time string which will work with Architect's ToDateTime expression function. If not, you can disregard the rest of this post. :slight_smile:

Assuming that string value is returned as an output and assigned to a Task.CrmDateTimeStr string variable, here is an expression you could use in a Decision action to see if the date time value is less than two months away from the current date time. In the expression below I also added a check to see if the Task.CrmDateTimeStr variable value is a NOT_SET or empty string as a safety check and in that case it will return false:

If(!IsNotSetOrEmpty(Task.CrmDateTimeStr), 
   ToDateTime(Task.CrmDateTimeStr) < AddMonths(GetCurrentDateTime(), -2), 
   false
)

If you're looking to use a Transfer to ACD action and it's only the queue that's different between the use cases of whether the date time is less than two months of where you want to transfer, it's possible to do this in the queue setting as an expression assuming all other settings on the Transfer to ACD action are the same. This would end up avoiding the use of a Decision action followed by two separate Transfer to ACD actions where one is configured to transfer to Queue A and the other to Queue B.

Again, not sure if it's applicable to your use case but assuming I had Queue A in a Task.QueueA variable and Queue B in a Task.QueueB variable, you could use this expression for the Queue setting on the Transfer to ACD action. In the expression Queue A in the Task.QueueA variable will be for when the date time is less than two months. Notice below how we use the boolean logic from expression above along with another logical If call and now the expression returns Queue A or Queue B from the queue variables which is what the Queue setting is looking for on the Transfer to ACD action:

If(
  If(!IsNotSetOrEmpty(Task.CrmDateTimeStr), 
     ToDateTime(Task.CrmDateTimeStr) < AddMonths(GetCurrentDateTime(), -2), 
     false
  ),
  Task.QueueA,
  Task.QueueB
)

Hope this helps,

Jim

This is perfect i think for our situation Jim. Thanks for that timely bit of info. I will test out the flow over the next couple of days. :slight_smile:

I tried what you suggested Jim and it wasn't working. When i played the outcome of the expression to audio i heard it state a date from 2 months previous so I changed "-2" to "2" to add 2 months from today's date and it worked. Thanks very much for the

e.g If(!IsNotSetOrEmpty(Task.CrmDateTimeStr),
ToDateTime(Task.CrmDateTimeStr) < AddMonths(GetCurrentDateTime(), 2),
false
)

Can you suggest any online resources that would help me understand what the expression helper in architect is trying to say but in more detail? I cannot find much at all. I find i get stuck on understanding the syntax and language used. For example - I didn't think it was possible to add a Boolean logic after the expression for selecting Queue A or Queue B.
,
Task.QueueA,
Task.QueueB
)

How would i configure this expression to add in a check if the CRMDATE is greater than todays date AND less that 2 months from today ? At present any date that is before today (in the past) up until 2 months from today is considered TRUE for the following expression. If(!IsNotSetOrEmpty(Task.CrmDateTimeStr),
ToDateTime(Task.CrmDateTimeStr) < AddMonths(GetCurrentDateTime(), 2),
false
)

You could wrap the "ToDateTime(Task.CrmDateTimeStr) < AddMonths(GetCurrentDateTime(), 2)," with another if where you will check if
ToDateTime(Task.CrmDateTimeStr) > GetCurrentDateTime())
in the true condition.

I could not get the ToDateTime(Task.CrmDateTimeStr) > GetCurrentDateTime()) to work. It kept coming up with errors no matter what i tried so i used this instead. If(!IsNotSetOrEmpty(Task.crmdate), ToDateTime(Task.crmdate) > AddMonths(GetCurrentDateTimeUtc(), 0), true) and that worked fine. Long way to achieve the same result. All my flows are working good now, thanks for your assistance.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.