Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Add a dynamic variable value for a entity names and attributes in fetchxml

Posted on by 315

Hello every body I'm new in thos comunity; I'm currently use The Kingsway Soft SSIS Integration Toolkit for Microsoft Dynamics 365(CRM) and in my CRM Source Component(Editor) I would like to add this string

<fetch mapping='logical'>
    <entity name='@[User::EntitiesName]'>
    <all-attributes />
    <filter type="and" >
      <condition attribute="modifiedon" operator="ge" value="@[User::ModifiedOn]" />
    </filter>
    </entity>
</fetch>

The @[User::EntitiesName] variable is build at runtime; Also the value @[User::ModifiedOn]  is build at runtime. I received the error

System.Exception: There was an error when retrieving the CRM metadata for the entity or FetchXML query provided.
KingswaySoft.IntegrationToolkit.DynamicsCrm.CrmServiceException:
 CRM service call returned an error: An error has occurred when retrieving metadata for CRM entity '': CRM service call returned an error:
 LogicalName is required when entity id is not specified(Error Code: -2147220989, Detail Message:
 LogicalName is required when entity id is not specified) (SSIS Integration Toolkit for Microsoft Dynamics 365, v8.1.0.6275 - devenv, v14.0.23107.0)
KingswaySoft.IntegrationToolkit.DynamicsCrm.CrmServiceException: CRM service call returned an error:
LogicalName is required when entity id is not specified(Error Code: -2147220989, Detail Message: LogicalName is required when entity id is not specified)
System.ServiceModel.FaultException<KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.OrganizationServiceFault>: LogicalName is required when entity id is not specified
(SSIS Integration Toolkit for Microsoft Dynamics 365, v8.1.0.6275 - devenv, v14.0.23107.0)

My Questions are

1) Is it a real error ? so I must type  at compilation time, the value for @[User::EntitiesName] ?

2) Can I pass dynamically @[User::EntitiesName] at run time ?

plese se the Image

 CaptureKingsWayCrmSource.PNG

Best regards 

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hi,

    Did this work out for you, can you able to store the value into variable?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    please send me the sample code. I am using Kingsway soft CRM source editor.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    If you are getting this count in code, cant you loop through the list of entities and run the query and get the count for each entity and add to total?

    Do you need sample code about how to run this fetch from C#?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    <fetch version="1.0" mapping="logical" aggregate="true">

     <entity name="account">

       <attribute name="accountid" aggregate="count" alias="count" />

     </entity>

    </fetch>

    this is working...but i have multiple entities to get record count, how to get for multiple entities

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hi,

    As my requirment, i have to get record count of all entities in dynamic crm, so i am trying to loop and pass each entity name as user variable. Please help me with passing the entiy name as variable. OR if there is an other way of getting record count of all entities. Thank you

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hi

    Please make sure when the values of the attributes are in double quotes and also make sure you use count aggregate as shown below

    <fetch version="1.0" mapping="logical" aggregate="true" >

     <entity name="incident" >

       <attribute name="ticketnumber" alias="Total" aggregate="count" />

     </entity>

    </fetch>

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hi,

    I have a similar requirement, i am trying get the count of records for all entities. Fetch XML does not work for unions, so i am trying to loop each entityname and get records.

    For now i hardcoded the 1 entity name and passing that user variable, but not working. Please shed some light.

    <fetch version="1.0" mapping="logical" aggregate="true">

     <entity name=@[User::tablename]>

       <attribute name=@[User::ColumnName] alias=@[User::tableAlias] aggregate="countcolumn" />

     </entity>

    </fetch>

  • Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hi,

    Try copying this code:

    <fetch mapping='logical'>
       <entity name=@[User::EntitiesName]>
       <all-attributes />
       <filter type="and" >
         <condition attribute="modifiedon" operator="ge" value=@[User::ModifiedOn] />
       </filter>
       </entity>
    </fetch>


    I removed the quotes from the parameters. I believe that they don't need quotes around them.

    Apologies if you have done this already.

  • Gmanunta81 Profile Picture
    Gmanunta81 315 on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Hello Thomas ,Hello Daniel

    I attached some scrennshot about

    the problem is regarding Ole DB Destination that saves the data Mapping at design time
    I attached the Screenshot images

    GENERAL FLOW

    CaptureKingsWayControlFlow.PNG

    DATA ABOUT EACH DINAMIC ITERATION

    CaptureKingsWayIteration.PNG

    FETCH XML OF DATA FLOW  KWS CRM SOURCE

    CaptureKingsWayFetch.PNG

    OLE DB DESTINATION DINAMICS PARAMETER

    CaptureKingsDBDest.PNG

    Do you have any advice ?

    thanks in advance

  • Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: Add a dynamic variable value for a entity names and attributes in fetchxml

    Possibly supply us with some screenshots of your SSIS like your CRM Source and your parameters. Just to get a more clear idea of whats going on.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans