Quantcast
Viewing all articles
Browse latest Browse all 46379

PreOperation plugin creating entity gets Record is unavailable error

Hi Experts,

Excuse my novice question...

In my plugin (registered PreOperation) on the create of a contract I am trying to create a document location record.  When the create fires on the document location I get the error "Record Is Unavailable The requested record was not found or you do not have sufficient permissions to view it."  I am system admin and that entity is "wide open" so I know I have permissions to create but is it that the plugin is not allowed at the state it is in.

Code.....

normal plug in stuff....

// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId);

......other code that works followed by 

// Create a SharePoint site record named Sample SharePoint Site.
SharePointDocumentLocation docLocation = new SharePointDocumentLocation();
docLocation.Name = "Document on SharePoint";
docLocation.AbsoluteURL = documenturl;
tracingService.Trace("SharePointHierarchicalFoldersPlugIn: entity id guid is : " + entity.Id.ToString());
docLocation.RegardingObjectId = new EntityReference(entity.LogicalName,entity.Id);
tracingService.Trace("SharePointHierarchicalFoldersPlugIn: docLocation Regarding insta : " + docLocation.RegardingObjectId.Id.ToString());
docLocation.Id = crmService.Create(docLocation);
tracingService.Trace("SharePointHierarchicalFoldersPlugIn: doclocation was created");

.....the boom happens at the crmService.Create.  Shouldn't I be able to create the document location record from the plugin creating the contract entity?  Any guidance is greatly appreciated.

Diane


Viewing all articles
Browse latest Browse all 46379

Trending Articles