Checking dates in Workflow Transition Rule

Hi

Probably I’m missing something, but I don’t find a simply way to do this.

I’m wondering if exists a easy way to check availability of a transition workflow rule depending of a date field in the same way as we can do on the escalations rules.

Maybe with an example will be more clear.

In escalation rule we can check dates putting on the SQL Clause this:

Oppo_somedate < #T

I’d tried this on a transition rule, putting this on the Javascript condition:

Valid = (Oppo_somedate < #T)

But don’t work at all.

Then tried this :

var now = new  Date();
Valid = (oppo_somedate < now)

And it seems to work, more or less…

After being changed the opportunity it doesn’t check properly the condition. But after refreshing the screen, it works.

 

Finally tried this:

Valid = false;
var oppoid = CRM.GetContextInfo("opportunity", "oppo_opportunityid");
if (typeof oppoid != "undefined") {
   Query= CRM.CreateQueryObj("select oppo_opportunityid from vopportunity where oppo_somedate < getdate() and oppo_opportunityid ="+oppoid);
   Query.SelectSql();
   if (!Query.eof)  //opportunity found
       Valid = true;
}

Which works perfectly but looks complicated for doing a simple thing like this.

 

Any thoughts ?