简体   繁体   中英

Converting an entity attribute to string for condition clause in FetchXML

I need to write a query that returns all entries that have a certain decimal attribute that begins with a certain number string.

Something like

...
WHERE TO_STRING(numerical_attribute) LIKE '%' || my_substring
...

So, for instance, if query the entries where the decimal attribute beings with "92", I'd like to recover, for instance, those entries where the attribute = 92, 924, 92.40, 92345592, etc.

Is there anyway to write that in the FetchXML filter? I tried this:

<filter>
    <condition attribute='numerical_attribute' operator='like' value='my_substring%' />
</filter>

But CRM returns that it is expecting a decimal value in "value".

MSDN doesn't provide a good documentation about FetchXML operators, but we can assume that the like operator requires a string attribute for matching.

The obvious workaround is to create a text field inside your entity and keep it synchronized with the decimal value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM