Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Under review by Community Managers

Under review

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

Cross-entity navigation inside a Plugin (Error Not found)

Posted on by

Hello EveryOne,

I have 2 custom entities, the Postulacion entity and the Matricula entity, 

I create the Matricula record inside the Postulacion Plugin (Stage: Pre Operation - sync) :



private Guid CrearMatricula(IOrganizationService servicio, ITracingService tracingService, Entity eMatricula, Guid gOportunidad, EntityReference erCliente)
{
...
Matricula.Id = servicio.Create(eMatricula);
...

}

So far so good, the problem is when within that same plugin (Now Post Operation - sync)
I try to call the Cross-entity navigation Endpoint using the recently created Matricula.Id
 the endpoint response is "Not Found"



 Cross-entity navigation Code :

var jCuerpo = (dynamic)new JObject();
jCuerpo.traversedpath = "ed1c90a4-d769-4089-950a-baba331db0bd,2c633484-48f8-4816-9c24-c406ee3b74cd,6d92c079-2378-4e98-93da-6a737afb779b,566bc8bc-97e8-43c5-8be3-fb15316b19b0";
jCuerpo["bpf_onetoone_matriculaid@odata.bind"] = "/onetoone_matriculas(" + context.SharedVariables["MatriculaId"].ToString() + ")";

string sUrlEndPoint = ""xxxx.crm2.dynamics.com/.../onetoone_1to1utppregrados(" + gInstanciaFlujoId.ToString() + ")";
tracingService.Trace("url Endpoint: " + sUrlEndPoint);
tracingService.Trace("Cuerpo: " + jCuerpo.ToString());

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
client.DefaultRequestHeaders.Add("OData-Version", "4.0");


client.BaseAddress = new Uri(sUrlEndPoint);
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("PATCH"), "")
{
Content = new StringContent(jCuerpo.ToString(), Encoding.UTF8, "application/json")
};

HttpResponseMessage response = client.SendAsync(request).Result;


The code is correct because when I replace the matriculaId with a previously created one, the call to the Endpoint ends correctly,
also the matriculaid value is always there, I have already obtained the traces and the value is there. What I have thought as the creation
of Matricula Record is done recently still does not exist before finalizing the Plugin execution (post Operation), but I am not totally convinced,
please I would appreciate any advice,


Antony

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans