web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error Adding Connections using REST and oData in Silverlight

(0) ShareShare
ReportReport
Posted on by 10

Whenever I try to add a new Connection, I get an Exception whose InnerException.Message is "Both objects being connected are missing".

When I step through my code, all the values resolve and are set as indicated in the connToInsert object, but the exception is thrown when the result is retrieved in the OnCreateConnectionComplete method.

I can verify that the Guid values are correct for the Task activity and the Account entity that I'm trying to connect. I can verify that the Task and Account LogicalName variables are set correctly. I can verify that there exists a ConnectionRole called "Activity" and that Task is one of the record types for which it is valid. I can verify that there exists a ConnectionRole called "Company" and that it is valid for the Account entity. And I can verify that the Guid values for these ConnectionRole entities are indeed the ones passed into the new Connection object I'm trying to create.

Has anyone seen this behavior before and, if so, how did you resolve the issue?

My code is as follows:

//pasted from within btnConnect_Click()

Connection connToInsert = new Connection();

connToInsert.Name = theItem.Company.Name; //string variable that resolves properly

connToInsert.Record1Id.Id = new Guid(_activity_id); //activity ID as class variable

connToInsert.Record1Id.LogicalName = _activity_typename; // "task"

connToInsert.Record1RoleId.Id = _activity_connectionRole_Id; // known connection role

connToInsert.Record1RoleId.LogicalName = "connectionrole";

connToInsert.Record2Id.Id = theItem.Company_ID; //Guid variable that resolves properly

connToInsert.Record2Id.LogicalName = "account";

connToInsert.Record2RoleId.Id = _company_connectionRole_id; //known connection role

connToInsert.Record2RoleId.LogicalName = "connectionrole";

_context.AddToConnectionSet(connToInsert);

_context.BeginSaveChanges(OnCreateConnectionComplete, connToInsert);

private void OnCreateConnectionComplete(IAsyncResult result)

{

try

{

_context.EndSaveChanges(result);

Connection createdConn = result.AsyncState as Connection;

lblStatus.text ="Created new connection";

}

catch(SystemException se)

{

throw;

}

}

Thanks,

John

*This post is locked for comments

I have the same question (0)
  • Verified answer
    ichuta Profile Picture
    10 on at

    I have resolved this issue.

    In Silverlight, the EntityReference entity has only one constructor, with no parameters. That is why I was assigning values directly to the Id fields' properties. Doing the following instead allowed the Connection to be created:

    EntityReference record1Id = new EntityReference();

    record1Id.Id = new Guid(_activity_id);

    record1Id.LogicalName = _activity_typename;

    connToInsert.Record1Id = record1Id;

    And so forth for Record2Id, Record1RoleId, and Record2RoleId.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans