Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a Lookup to existing entity #65

Closed
StewUK opened this issue Jun 14, 2018 · 4 comments
Closed

Creating a Lookup to existing entity #65

StewUK opened this issue Jun 14, 2018 · 4 comments

Comments

@StewUK
Copy link

StewUK commented Jun 14, 2018

Hi

I am trying to create an entity, but give it a lookup to an existing entity.

Is this possible? Currently the Create is also trying to generate the lookup entity, which fails as a key already exists.

Thanks

@davidyack
Copy link
Owner

Can you show some code - how are you setting the lookup reference?

@StewUK
Copy link
Author

StewUK commented Jun 14, 2018

`dynamic newCustomEntity = new ExpandoObject();
newCustomEntity.value1 = "blah";
newCustomEntity.value2 = "anotherblah";

dynamic primaryContact = new ExpandoObject();
primaryContact.contactid = Guid.Parse(contactIdParameter);

newCustomEntity.contactlookup_id = primaryContact;

var result = await crmAPI.Create("new_customentity", newCustomEntity); `

Can't get it to paste as code, but that should show what I'm trying to achieve (probably incorrectly)

@StewUK
Copy link
Author

StewUK commented Jun 19, 2018

Hi @davidyack just wondered if you had any ideas about this? I'd rather stick with your solution than go with the full framework and the SDK.

My goal is to create a child entity, then link it to a parent entity. Is there a better way to achieve this?

Thanks in advance

@davidyack
Copy link
Owner

Sorry I missed the notification on your prior message - if the contact already exists your contactlookup_id needs to have a value more like "/contacts(guid)" assuming contactlookup_id is in fact your correct navigation property and contact is an existing record

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants