Post

1 follower Follow
0
Avatar

Type casting while executing query using api

Josh Santos asked to duplicate post in this forum ( https://success.clarizen.com/entries/27475156 )

 

Hello,

I am trying to get results with query usiing condition FieldA > FieldB

 

 

$conditionIssue = new stdClass();

$fld = new stdClass();

$fld->FieldName = "FieldA";

$conditionIssue->LeftExpression = new SoapVar($fld, SOAP_ENC_OBJECT, 'FieldExpression', $this->soapQApiUrl);

$conditionIssue->Operator = "GreaterThan";

$fld = new stdClass();

$fld->FieldName = "FieldB";

$conditionIssue->RightExpression = new SoapVar($fld, SOAP_ENC_OBJECT, 'FieldExpression', $this->soapQApiUrl);

 

 

But FieldA is Numeric and FieldB is Duration

Is there any way to cast types for comparsion?

Thank you,

Oleg Savich Answered

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Oleg.

Comparing between fields is a surprising implementation of the Compare condition. Most implementation use a ConstantExpression or a QueryExpression for the right expression (available when the field on the condition is a reference).

Comparing between fields seems to be working, but I can't say it's officially supported and recommended. You may want to choose a more conservative implementation, i.e. reading all relevant entities from Clarizen and filtering the results.

Having said that,  Duration fields have a numeric value in working days (as per the default hours per work day in the organization calendar). I managed to implement such Compare condition between a Duration & numeric fields. 

If your numeric field's value is not in working days, I'd suggest you use Customization to setup a formula field that does the 'unit' conversion, or maybe better still check if FieldA is greater than FieldB leaving more standard conditions work for the API. 

Ophir Kenig 0 votes
Comment actions Permalink