Complex Expression

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Complex Expression

Edgardo Vega
I am trying to route on attribute and have created a complex expression but
I get a validation error.

${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(now():minus(3600000))}

It seems like less than function only supports a number not an expression
or an attribute name.

How can I accomplish what I am trying to do? I am just trying to route
based if created_at is older than an hour?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Complex Expression

Mark Payne
Edgardo,


Try:






${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):toNumber():lt(now():minus(3600000))}



That toNumber() call will convert the date into milliseconds since epoch. That should allow you to easily compare against the other number.


Thanks

-Mark






From: Edgardo Vega
Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎39‎ ‎AM
To: [hidden email]





I am trying to route on attribute and have created a complex expression but
I get a validation error.

${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(now():minus(3600000))}

It seems like less than function only supports a number not an expression
or an attribute name.

How can I accomplish what I am trying to do? I am just trying to route
based if created_at is older than an hour?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Complex Expression

Edgardo Vega
Mark,

The documentation for toDate say that it returns a number so going from a
number to a number doesn't fix the problem. The validation message says it
is invalid because Unexpected token 'now' at line 1....

If I type a number say 100 so ${created_at:toDate("yyyy-MM-
DD'T'HH:mm:ss.SSS'Z'"):lt(100)} I validates fine anything else throws a
validation message.

Cheers,

Edgardo


On Wed, May 6, 2015 at 10:40 AM, Mark Payne <[hidden email]> wrote:

> Edgardo,
>
>
> Try:
>
>
>
>
>
>
>
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):toNumber():lt(now():minus(3600000))}
>
>
>
> That toNumber() call will convert the date into milliseconds since epoch.
> That should allow you to easily compare against the other number.
>
>
> Thanks
>
> -Mark
>
>
>
>
>
>
> From: Edgardo Vega
> Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎39‎ ‎AM
> To: [hidden email]
>
>
>
>
>
> I am trying to route on attribute and have created a complex expression but
> I get a validation error.
>
>
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(now():minus(3600000))}
>
> It seems like less than function only supports a number not an expression
> or an attribute name.
>
> How can I accomplish what I am trying to do? I am just trying to route
> based if created_at is older than an hour?
>
> Thanks in advance
>



--
Cheers,

Edgardo
Reply | Threaded
Open this post in threaded view
|

Re: Complex Expression

Mark Payne
In reply to this post by Edgardo Vega
Edgardo,


Sorry, completely misunderstood the problem. You’re right.


The issue is that when you use the “now” function, it has to be the first thing in the Expression. So to do what you're wanting, you’ll have to embed a new expression:


${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt( ${now():minus(3600000)} )}


That should do it for you. If not, let me know!


Thanks

-Mark









From: Edgardo Vega
Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎51‎ ‎AM
To: [hidden email]





Mark,

The documentation for toDate say that it returns a number so going from a
number to a number doesn't fix the problem. The validation message says it
is invalid because Unexpected token 'now' at line 1....

If I type a number say 100 so ${created_at:toDate("yyyy-MM-
DD'T'HH:mm:ss.SSS'Z'"):lt(100)} I validates fine anything else throws a
validation message.

Cheers,

Edgardo


On Wed, May 6, 2015 at 10:40 AM, Mark Payne <[hidden email]> wrote:

> Edgardo,
>
>
> Try:
>
>
>
>
>
>
>
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):toNumber():lt(now():minus(3600000))}
>
>
>
> That toNumber() call will convert the date into milliseconds since epoch.
> That should allow you to easily compare against the other number.
>
>
> Thanks
>
> -Mark
>
>
>
>
>
>
> From: Edgardo Vega
> Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎39‎ ‎AM
> To: [hidden email]
>
>
>
>
>
> I am trying to route on attribute and have created a complex expression but
> I get a validation error.
>
>
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(now():minus(3600000))}
>
> It seems like less than function only supports a number not an expression
> or an attribute name.
>
> How can I accomplish what I am trying to do? I am just trying to route
> based if created_at is older than an hour?
>
> Thanks in advance
>



--
Cheers,

Edgardo
Reply | Threaded
Open this post in threaded view
|

Re: Complex Expression

Edgardo Vega
Mark,

That worked like a champ.

Thanks,

Edgardo

On Wed, May 6, 2015 at 10:55 AM, Mark Payne <[hidden email]> wrote:

> Edgardo,
>
>
> Sorry, completely misunderstood the problem. You’re right.
>
>
> The issue is that when you use the “now” function, it has to be the first
> thing in the Expression. So to do what you're wanting, you’ll have to embed
> a new expression:
>
>
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(
> ${now():minus(3600000)} )}
>
>
> That should do it for you. If not, let me know!
>
>
> Thanks
>
> -Mark
>
>
>
>
>
>
>
>
>
> From: Edgardo Vega
> Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎51‎ ‎AM
> To: [hidden email]
>
>
>
>
>
> Mark,
>
> The documentation for toDate say that it returns a number so going from a
> number to a number doesn't fix the problem. The validation message says it
> is invalid because Unexpected token 'now' at line 1....
>
> If I type a number say 100 so ${created_at:toDate("yyyy-MM-
> DD'T'HH:mm:ss.SSS'Z'"):lt(100)} I validates fine anything else throws a
> validation message.
>
> Cheers,
>
> Edgardo
>
>
> On Wed, May 6, 2015 at 10:40 AM, Mark Payne <[hidden email]> wrote:
>
> > Edgardo,
> >
> >
> > Try:
> >
> >
> >
> >
> >
> >
> >
> >
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):toNumber():lt(now():minus(3600000))}
> >
> >
> >
> > That toNumber() call will convert the date into milliseconds since epoch.
> > That should allow you to easily compare against the other number.
> >
> >
> > Thanks
> >
> > -Mark
> >
> >
> >
> >
> >
> >
> > From: Edgardo Vega
> > Sent: ‎Wednesday‎, ‎May‎ ‎6‎, ‎2015 ‎10‎:‎39‎ ‎AM
> > To: [hidden email]
> >
> >
> >
> >
> >
> > I am trying to route on attribute and have created a complex expression
> but
> > I get a validation error.
> >
> >
> >
> ${created_at:toDate("yyyy-MM-DD'T'HH:mm:ss.SSS'Z'"):lt(now():minus(3600000))}
> >
> > It seems like less than function only supports a number not an expression
> > or an attribute name.
> >
> > How can I accomplish what I am trying to do? I am just trying to route
> > based if created_at is older than an hour?
> >
> > Thanks in advance
> >
>
>
>
> --
> Cheers,
>
> Edgardo
>



--
Cheers,

Edgardo