Skip to main content

Notifications

Announcements

No record found.

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

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);
//...

return Matricula.Id;
 }


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

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