0

我有以下获取 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>

知道怎么做吗?

谢谢和最好的问候..

4

1 回答 1

2

如果问题是为什么您的 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)
于 2013-05-24T20:21:11.380 回答