gpt4 book ai didi

javascript - 客户关系管理 2011 : Insert condition to a fetchXML query using javascript

转载 作者:行者123 更新时间:2023-12-02 18:42:21 25 4
gpt4 key购买 nike

我有以下获取 XML 查询:

<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>

我有一个业务需求,需要使用 java 脚本插入以下条件:

<condition attribute='new_entityid' operator='eq' value='10ad18f6-c384-e211-b04d-78e3b50834b8'/>

最终的fetchxml如下:

<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>

知道如何做到这一点吗?

谢谢并致以诚挚的问候..

最佳答案

如果问题是为什么您的提取不起作用,可能是因为您的属性嵌套在节点中。尝试这样:

<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>

如果问题是你如何插入你的JS。您可以使用这样的正则表达式( jsFiddle ):

var regex = new RegExp(/<link-entity.*name=[\"\']new_entity[\"\'].*>.*<filter[^>]*>/);

fetch = fetch.replace(regex, '$&' + newCondition)

关于javascript - 客户关系管理 2011 : Insert condition to a fetchXML query using javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16724957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com