I have the following fetch XML query:
<fetch mapping="logical">
<entity name="salesorder">
<attribute name="salesorderid"/>
<attribute name="new_type"/>
<attribute name="new_solomonswonumber"/>
<attribute name="new_resolutioncode"/>
<attribute name="new_rentalsaleindicator"/>
<attribute name="new_preferredphone"/>
<attribute name="name"/>
<attribute name="new_equipment"/>
<attribute name="customerid"/>
<order attribute="new_type" descending="false"/>
<filter type="and">
<condition attribute="salesorderid" operator="eq" value="5AC5CBAC-25A0-E211-92B3-00155D815016"/></filter>
<link-entity name="new_entity" from="new_entityid" to="new_entitylookup">
<filter type="and">
<attribute name="new_street1"/>
<attribute name="new_province"/>
<attribute name="new_postalcode"/>
<attribute name="new_city"/>
</filter>
</link-entity>
</entity></fetch>
I have a business need where I need to insert the following condition using java script:
<condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/>
So that the final fetchxml is as follow:
<fetch mapping="logical">
<entity name="salesorder">
<attribute name="salesorderid"/>
<attribute name="new_type"/>
<attribute name="new_solomonswonumber"/>
<attribute name="new_resolutioncode"/>
<attribute name="new_rentalsaleindicator"/>
<attribute name="new_preferredphone"/>
<attribute name="name"/>
<attribute name="new_equipment"/>
<attribute name="customerid"/>
<order attribute="new_type" descending="false"/>
<filter type="and">
<condition attribute="salesorderid" operator="eq" value="5AC5CBAC-25A0-E211-92B3-00155D815016"/></filter>
<link-entity name="new_entity" from="new_entityid" to="new_entitylookup">
<filter type="and">
<condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/>
<attribute name="new_street1"/>
<attribute name="new_province"/>
<attribute name="new_postalcode"/>
<attribute name="new_city"/>
</filter>
</link-entity>
</entity></fetch>
Any idea how to do this ?
Thanks and best regards..
If the question is why your fetch isn't working, it might be because you have your attributes nested in your node. Try it like this:
<fetch mapping="logical">
<entity name="salesorder">
<attribute name="salesorderid"/>
<attribute name="new_type"/>
<attribute name="new_solomonswonumber"/>
<attribute name="new_resolutioncode"/>
<attribute name="new_rentalsaleindicator"/>
<attribute name="new_preferredphone"/>
<attribute name="name"/>
<attribute name="new_equipment"/>
<attribute name="customerid"/>
<order attribute="new_type" descending="false"/>
<filter type="and">
<condition attribute="salesorderid" operator="eq" value="5AC5CBAC-25A0-E211-92B3-00155D815016"/></filter>
<link-entity name="new_entity" from="new_entityid" to="new_entitylookup">
<filter type="and">
<condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/>
</filter>
<attribute name="new_street1"/>
<attribute name="new_province"/>
<attribute name="new_postalcode"/>
<attribute name="new_city"/>
</link-entity>
</entity></fetch>
If the question is how do you insert you JS. You can use a regex like this ( jsFiddle ):
var regex = new RegExp(/<link-entity.*name=[\"\']new_entity[\"\'].*>.*<filter[^>]*>/);
fetch = fetch.replace(regex, '$&' + newCondition)
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.