Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Related Virtual Entities and Invalid Argument error

Posted on by Microsoft Employee
Hi all,
I have another Virtual Entity issue. 
I have a single custom entity provider that is returning multiple types of virtual entities.  Since they are all coming from the same provider, I can use the same data source for all of them.
I have one virtual entity (TerminalCard) that references another virtual entity (Terminal).  The field is defined in CRM as a lookup on the entity to the other. 
So each TerminalCard references one Terminal, but a Terminal can be referenced by multiple TerminalCards.
In my custom provider, I am setting the Terminal ID field of the TerminalCard to the ID of the Terminal that it references, making sure that it's a GUID.  I think that I have set up the external names correctly: the external name of the TerminalCard field for the TerminalID is the same as the external name of the ID for Terminal:
So I have something like:
Terminal ID field:
Name: new_terminalid
External Name: new_terminalid

TerminalCard lookup field:
Name: new_terminalid
External Name: new_terminalid

I can retrieve Terminals without a problem (using Advanced Find, for instance).  When I try to retrieve TerminalCards, I get an 'Invalid Argument' error, and no log file to download (so I can't actually see what's wrong):
0160.InvalidArgument.png
I know one common cause of this is when two virtual entities are coming from different data sources; but I'm very confident that they are coming from the same data source, since I only have one. (Side note: I initially didn't realize you could have more than one entity returned from a data provider, so I had two.  I wasn't even allowed to set up the relationship because of this, which is why I think I'm good here).
I see that my plug-in is called in the Plug In Trace log, and I see no exceptions.  Note that only the TerminalCards retrieve is called before the error; I don't see the Terminal call. 
Note that if I remove the relationship (for example, just making the ID a string field), I'm able to retrieve the TerminalCards, and the ID value is set to the correct TerminalID.  The error only happens when the relationship is present (which I really need for filtering).
So I have several questions;
- In the call to retrieve the TerminalCards, I'm only returning the TerminalCards; I'm not building Terminal entities and attaching them.  Do I need to do this?
- Is there any way to get more details about the error?
- Are there any examples of custom data providers with related virtual entities?  I've seen examples using the OData provider, but I'm not using that.
Any other tips or ideas are appreciated - thanks.

*This post is locked for comments

  • Krutika S Profile Picture
    Krutika S 20 on at
    RE: Related Virtual Entities and Invalid Argument error

    Hi Peter,

    Have you got solution for this issue? I have 1:N relationship between two virtual entities and it gives me 'Invalid argument' error when I load a form. Tried various solutions but no luck so far.

    Best regards,

    Krutika

  • AP Hogeschool Profile Picture
    AP Hogeschool 5 on at
    RE: Related Virtual Entities and Invalid Argument error

    Hi Philmar

    I have got the same problem whith one-to-many relationship between two Virtual Entities.

    Did you find a solution?

    I will be grateful for any help you can provide.

    Best regards

    Peter

  • Suggested answer
    StefanS365 Profile Picture
    StefanS365 3,573 Most Valuable Professional on at
    RE: Related Virtual Entities and Invalid Argument error

    Hi philmar,

    You could try the fix that is mentioned in the 'This step is important' section of the following blog post:

    dreamingincrm.com/.../using-virtual-entities-to-query-metadata

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans