Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

WebApi Query for Multiple Linked entities

Posted on by 395

Hi,

I am trying to build a webapi query for the multiple associated entities. I need to find whether a contact has been associated to multiple entities? Ex: If a contact is associate to Account, Lead or Opportunity. I should get those results. I tried with CRM rest builder but some how its throwing an error.

*This post is locked for comments

  • RE: WebApi Query for Multiple Linked entities

    33

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi Query for Multiple Linked entities

    Again log that I saw - Value of 'Record Reference' attribute equals to empty says that nothing is passed as a reference to record. Fix this - fix the problem.

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: WebApi Query for Multiple Linked entities

    Hi Andrew,

    Yes i tried with Record Url as well but no luck. I couldn't figure out the issue but proceed with other options to finish with the work.

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: WebApi Query for Multiple Linked entities

    Hi Andrew,

    I tried with that one too but didn't work. Couldn't figure out the problem. Proceed with the query to finish the work. Let me know if you want me to share the in detailed steps what i have done. I tried on a MS trial environment.

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi Query for Multiple Linked entities

    Ok, can you please confirm that you pass Dynamic Record Url as it is mentioned here - github.com/.../Record-Reference---polymorphic-lookup

    I believe that's why it doesn't work as it should.

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: WebApi Query for Multiple Linked entities

    Hi Andrew,

    Sorry for the confusion. I did make that field name change after your first comment by mistake i have included old screen shot. Here is the actual one. I have created the workflow on Contact entity (Work Flow Screen shot is included above). Do i need to setup any thing on Account ? 

    WorkFlow-Step.

    Account_2D00_Screen.PNG

    Account Screen

    Account_2D00_Screen.PNG

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi Query for Multiple Linked entities

    I can tell you what my code says - Record Reference input is empty.

    The next one - don't pass to fieldname field from crm. Pass logical name of field - new_fieldname or so. I wrote this in my previous reply, please, be attentive.

    Lastly - can you please post a screenshot of account from which you test your workflow?

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: WebApi Query for Multiple Linked entities

    I have checked the data for the lookup. It has associated record and made the change in field name too but i dont see any change and still seeing the null reference exception. I am sure i may be doing some thing wrong. Its related to the contact primary field on Account form. Is there any way i can get some steps . Here is what i have done.

    1. I have created a Rollup field on Contact. Checking whether any Primary Contact exist for the account. My Rollup field is giving correct value when i manually refreshed the field.

    RollupWorkflow.PNG

    2. Created a work Flow and picked your Calculate Rollup Field. In work flow picked the below fields but the Primary Contact always coming as empty not sure why.  I have checked the relationship and it exist properly.

    RollupWorkflow.PNG

    7271.Rollup.PNG

    Any thing that you can suggest whether i am missing any thing?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi Query for Multiple Linked entities

    So answer is simple - reference to record you want to pass is empty - lookup just doesn't have any data inside... The other mistake - Rollup field name expects for field name like new_fieldname. Change it and it should work.

  • Srini20 Profile Picture
    Srini20 395 on at
    RE: WebApi Query for Multiple Linked entities

    5482.Rollup.PNG

    Thank you. I tried this and got the below error. Am i doing any thing wrong? I have the Roll-up field on Contact form. Attached the screen shot as well.

    UltimateWorkflowToolkit.CoreOperations: UltimateWorkflowToolkit.CoreOperations.System.RecalculateRollup]

    [UWT: System: Recalculate Rollup Field]

    Value of 'Record Reference' attribute equals to empty

    Value of 'Rollup Field Name' attribute equals to 0

    Value of 'Throw an Exception on Error' attribute equals to True

    Error Message:

    Unhandled Exception: Microsoft.Crm.CrmException: Unexpected exception from plug-in (Execute): UltimateWorkflowToolkit.CoreOperations.System.RecalculateRollup: System.Exception: Error converting string '' to EntityReference - Value cannot be null.

    Parameter name: value

      at Microsoft.Crm.Sandbox.SandboxCodeUnit.ProcessException(Exception originalException, IExecutionContext context, SandboxClient client, SandboxCallTracker callTracker, Boolean isSafeToRetry, DateTime performanceExecutionStartTime, SandboxTracker tracker, Guid parentExecutionId, CrmException& crmException, String& assemblyContents)

      at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)

      at Microsoft.Xrm.RemotePlugin.CrmProvider.RemotePlugin.Execute(IServiceProvider serviceProvider)

      at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans