Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchXml for Liquid as an one of the outputs #264

Open
ZaarourOmar opened this issue Oct 8, 2019 · 5 comments
Open

FetchXml for Liquid as an one of the outputs #264

ZaarourOmar opened this issue Oct 8, 2019 · 5 comments

Comments

@ZaarourOmar
Copy link

Hi,
It would be great if one of the output is a liquid formatted FetxhXml call that can be copied and pasted in a portal web template and ready for consumption.

@rappen
Copy link
Owner

rappen commented Oct 9, 2019

Sounds like a good idea!
I have not worked with portals that much - how would that format look?

@ZaarourOmar
Copy link
Author

Sounds like a good idea!
I have not worked with portals that much - how would that format look?

Yes, so basically, one of the very common uses in Portal is to create a webtemplate that contains a fetxhxml mixed with liquid syntax to be used to query data from CRM and use it on the page. People with less knowledge in liquid will benefit from having a fetxhxml query converted to a liquid fetxhxml query with results being formatted as JSON or XML. This post by Colin Vermander outlines how it is formatted and used.

https://colinvermander.com/2017/04/17/dynamics-365-portals-use-liquid-to-return-json-or-xml/

@rappen
Copy link
Owner

rappen commented Oct 11, 2019

To me it looks like plain fetchXML there, with some embedded liquid parametrization. But how would FXB know where the developer would want to inject liquid?
Perhaps @koolin could have some ideas or clarify what I am not understanding?

@koolin
Copy link

koolin commented Oct 11, 2019

Perhaps the ask is to sub/replace values of attributes with liquid syntax attributes? Or to create the wrapping required to add the fetch in liquid?

`{% fetchxml my_query %}
  <fetch version="1.0" mapping="logical">
    <!-- Write FetchXML here, use Liquid in here if you want, to build XML dynamically. -->
  </fetch>
{% endfetchxml %}
  
{{ my_query.xml | escape }}
{{ my_query.results.total_record_count }}
{{ my_query.results.more_records }}
{{ my_query.results.paging_cookie | escape }}
{% for result in my_query.results.entities %}
  {{ result.id | escape }}
{% endfor %}`

<condition attribute="dpx_courselocationid" operator="eq" value="{{ request.params['location'] | xml_escape }}" />

For the condition really sure something like that actually would be feasible considering the potential variations and unknowns in how someone might use the liquid or the logic they require. I use fetchXML builder today to build the normal fetch and then go about adding specific logic as required in liquid.

@ZaarourOmar
Copy link
Author

I actually meant the wrapping and the JSON/XML creation. I agree that the above mentioned snippet by Colin is not always the case but it is easier to modify that snippet than to build it from scratch. Thanks Colin and Jonas :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants