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

Community site session details

Session Id :
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

I have the same question (0)
  • a33ik Profile Picture
    84,331 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();

  • Harshith Profile Picture
    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.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator 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
    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

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator 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/

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 138 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 107

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 89

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans