Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

GUID of the Record not found in POST operation.

(0) ShareShare
ReportReport
Posted on by 50

HI , 

i Am working with two Tables Application and Application Process , i am Creating Application Process record within the plugin that runs POST operation to Create of Application.

While Mapping Application to Application Process as a Look up , i am getting an error stating Application with GUID does not Exist even when i am running it in Post operation.

Please help me identify the issue

Sharing the Code Below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;
using System.ServiceModel;
using Microsoft.Xrm.Sdk.Query;
using System.Text.RegularExpressions;
using Microsoft.Crm.Sdk.Messages;

namespace MyPlugins
{
public class ApplicationProcess_Save : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{

ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));


IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));

// Obtain the organization service reference which you will need for
// web service calls.
IOrganizationServiceFactory serviceFactory =
(IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

// The InputParameters collection contains all the data passed in the message request.
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity appCreate = (Entity)context.InputParameters["Target"];

try
{

Entity APentity = new Entity("ijp_applicationprocess");

APentity.Attributes["ijp_application"] = new EntityReference("ijp_application", context.PrimaryEntityId);
APentity.Attributes.Add("ijp_ijp", (EntityReference)appCreate["ijp_ijp"]);
APentity.Attributes.Add("ijp_hrms", hrmsEntity.ToEntityReference());
APentity.Attributes.Add("ijp_name", hrmsEntity["ijp_employeename"]);
APentity.Attributes.Add("ijp_directmanager", hrmsEntity["ijp_directmanager"]);
Guid CreateAP = service.Create(APentity);

// i am getting an error stating GUID of application not found in the  above line

}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("An error occurred in MyPlug-in.", ex);
}

catch (Exception ex)
{
tracingService.Trace("MyPlugin: {0}", ex.ToString());
throw;
}
}
}
}
Attaching the Snapshot of running the plugin post operation.

pastedimage1644332043995v2.png

Thanks,

Harshith

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: GUID of the Record not found in POST operation.

    Hi,

    Is there any reason why you have selected Execution value as 2 in your Post operation plugin?

    Can you try changing it to 1 and see if it works.

    Do you have any other business logic in your plugin or you are only creating Application process record when Application is created?

    Can you please share the plugin trace log error?

    I hope you are not checking and getting error while debugging, and also you have disabled your profiler.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Harshith Profile Picture
    Harshith 50 on at
    RE: GUID of the Record not found in POST operation.

    Hi Bipin ,

    Thanks for the reply

    I tried that as well i was just trying all possible Alternatives to use the record ID of target Entity.  But in Async it works.  i am trying to figure out why it is not working when I run it as synchronous.

    i am using another Plugin Pre operation on Create of same record (Error free Plugin the runs well), and this one is for post operation , wondering if that has to do anything with this. Because i had worked on similar use case and it was working fine where i just had one post operation plugin.

    Kindly help me with this.

    Thanks in Advance,

    Harshith

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: GUID of the Record not found in POST operation.

    Hi,

    Why don't you take Application record Id from Target Entity as below -

    APentity.Attributes["ijp_application"] = new EntityReference("ijp_application", appCreate.Id);

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Harshith Profile Picture
    Harshith 50 on at
    RE: GUID of the Record not found in POST operation.

    Hi Andrew,

    thanks for the quick reply

    I tried that one as well , like i am trying every possible way but GUID is not found its little Weird,  Plugins are being Intermittent for me.

    i am using another Plugin Pre operation on Create of same record (Error free Plugin the runs well), and this one is for post operation , wondering if that has to do anything with this. Because i had worked on similar use case and it was working fine where i just had one post operation plugin.

    Please share your thoughts on this !

    it works if i make second plugin Asynchronous maybe because there is some delay in executing Async requests.

    Thanks in Advance.

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: GUID of the Record not found in POST operation.

    Hello,

    Try to replace line

    APentity.Attributes["ijp_application"] = new EntityReference("ijp_application", context.PrimaryEntityId);

    with line

    APentity.Attributes["ijp_application"] = appCreate.ToEntityReference();

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

News and Announcements

Announcing Category Subscriptions!

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans