-
-
Notifications
You must be signed in to change notification settings - Fork 65
Description
So this is a quality of life request. But one thing I find a little annoying is when I need to copy a FetchXML query into the FetchXMLBuilder from Code, the code that we have almost always has some Dynamic Variables in it which get swapped out through String Interpolation.
However, because we have these dynamic variables, the query isn't always in a state where we can just execute it right away. We have to parse it out manually and then replace all of the instances in the query with the absolute value.
Examples:
<condition attribute='ex_datefield' operator='gt' value='{DateTime.UtcNow.ToString("O")}' /><condition attribute='ex_datefield' operator='gt' value='{DateTime.Today.ToString("O")}' /><condition attribute='ex_numberfield' operator='eq' value='{DateTime.Now.Year - 1}' />
Yeah, a lot of them have to do with Dates, would it be possible to add in support for limited formulas surrounding dates?
How I envision it is the FetchXMLBuilder tool before it submits the query to Dataverse would parse through for these dynamic tokens and then swap out the values before sending it.
It doesn't even really have to be C# code either. What would be really nice is if you could integrate the XRM Tokens Runner Engine and have the format use that. You could have us specify the formula in a custom attribute like so:
<condition attribute='ex_datefield' operator='gt' value='{DateTime.UtcNow.ToString("O")}' fxb-formula="<system|today|O>" />
And then when you paste in the query and click "OK" it could just replace whatever is in the value attribute with that formula. Or ideally it leaves the value that gets displayed alone so that we can just copy any changes back into our code if needed.
Ideally if we wen this approach, we'd probably want to integrate token support for the following from the Documentation (https://jonasr.app/xrm-tokens/)
- System (maybe expanded with an extra
utcnowoption for Dates) - Random
- Token Formatting
If we went this approach, we could then just specify in our code both the fxb-format and the value in code (what our code executes). And since the FetchXML Engine in Dataverse ignores unknown attributes, it make it easier to move contexts between Visual Studio and FXB.