Fetching irregular data from CRM Dynamics

谁都会走 提交于 2019-12-11 07:57:44

问题


I've created a fetch XML that gives me all the contacts in a marketing list. I also would like to get the name of the list baked into the output. I've found two ways to achieve that, none of which is satisfactory to the pedantic me.

  1. Go to the DB and fetch the name as a separate request.
  2. Have an extra column containing the name of the marketing list for each contact.

I'll be getting multiple (maybe even all) marketing lists from CRM so the second version seems most suitable as I'll make one call and get it all into a data structure that I'll play with (DataSet and such are fun). The problem is there that we're getting a lot of redundancy. How can I resolve that?


回答1:


Are you able to add the marketing list name into the fetch?

For example:

Query:

<fetch mapping="logical" count="50" version="1.0">
    <entity name="list">
        <attribute name="listname" />
        <link-entity name="listmember" from="listid" to="listid">
            <link-entity name="contact" from="contactid" to="entityid">
                <attribute name="fullname" />
            </link-entity>
        </link-entity>
    </entity>
</fetch>

Result:

<resultset morerecords="0" paging-cookie="&lt;cookie page=&quot;1&quot;&gt;&lt;listid last=&quot;{4EDF9ECA-A108-E211-801E-00155D505002}&quot; first=&quot;{4EDF9ECA-A108-E211-801E-00155D505002}&quot; /&gt;&lt;/cookie&gt;">
    <result>
        <listname>Test Marketing List Name</listname>
        <listid>{4EDF9ECA-A108-E211-801E-00155D505002}</listid>
        <entityid.fullname>James Maths Wood</entityid.fullname>
    </result>
    <result>
        <listname>Test Marketing List Name</listname>
        <listid>{4EDF9ECA-A108-E211-801E-00155D505002}</listid>
        <entityid.fullname>James Wood</entityid.fullname>
    </result>
    <result>
        <listname>Test Marketing List Name</listname>
        <listid>{4EDF9ECA-A108-E211-801E-00155D505002}</listid>
        <entityid.fullname>WoodJ Test</entityid.fullname>
    </result>
</resultset>

As a side have you seen the FetchXml builder included in the Stunnware Tools available from http://www.stunnware.com, its for Crm 4 but handles pretty much every 2011 fetch I've needed to create. Note: it didnt create the fetch for the marketing list above correctly, I had to change the link-entity to contact to contactid manually.



来源:https://stackoverflow.com/questions/12620358/fetching-irregular-data-from-crm-dynamics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!