FetchXML Greater Than
-
31-01-2021 - |
题
I am using FetxhXML and I want the condition to be greater than a certain number of hours.
This is what I have:
string groupby1 = "<fetch distinct='false' mapping='logical' aggregate='true'>" +
"<entity name='opportunity'>" +
"<attribute name='opportunityid' alias='opportunity_count' aggregate='countcolumn' />" +
"<filter type='and'>" +
"<condition attribute='new_leadstatus' operator='eq' value='100000000' />" +
"<condition attribute='new_emailedtorsm' operator='eq' value='false' />" +
"<condition attribute='ownerid' operator='not-null' />" +
"<condition attribute='createdon' operator='last-x-hours' value='1' />" +
"</filter>" +
"<attribute name='ownerid' alias='ownerid' groupby='true' />" +
"<link-entity name='systemuser' from='systemuserid' to='ownerid'>" +
"<attribute name='internalemailaddress' alias='internalemailaddress' groupby='true' />" +
"</link-entity>" +
"</entity>" +
"</fetch>";
So basically on the createdon condition I would want it to be greater than 1 hour or greater than the last x hours. Is this possible?
解决方案
You'll need to use the on-or-before condition and insert your own DateTime that is one hour before the current time, like so:
string groupby1 = string.Format(@"
//snip...
<condition attribute='createdon' operator='on-or-before' value='{0}' />
//snip...
", DateTime.Now.AddHours(-1).ToUniversalTime().ToString("u"));
不隶属于 StackOverflow