
Dear,
I know that the low code plugins are still in preview, but I thought I would give it a try anyway.
On editing an OpportunityProduct I am trying to delete another record using a plugin (Entity: OpportunityProduct, Message: Update, Stage: Post-Operation, Mode: Async), with the following code (with a hardcoded guid as example, which is different than the record the plugin is triggered from):
Remove(opportunityproduct, LookUp(opportunityproduct, opportunityproductid = GUID("18556dae-5593-ee11-be37-000d3aacaa23")))
giving the following error:
Start message: Update, stage=PostOp, etn=opportunityproduct baf25ed5-4693-ee11-be37-000d3aacaa23, ver=1.0.0.0
Object reference not set to an instance of an object., script: [compiled]Remove(opportunityproduct, LookUp(opportunityproduct, opportunityproductid = GUID("18556dae-5593-ee11-be37-000d3aacaa23"))), input: ???
Exception thrown: System.NullReferenceException: Object reference not set to an instance of an object.
at PowerPlexPlugin.DataverseServices.DeleteAsync(String entityName, Guid id, CancellationToken cancellationToken)
at Microsoft.PowerFx.Dataverse.DataverseTableValue.<RemoveAsync>d__18.MoveNext()
When trying the same through a canvas app with the equivalent code
Remove('Opportunity Products', LookUp('Opportunity Products', opportunityproductid = GUID("18556dae-5593-ee11-be37-000d3aacaa23")))
it works fine.
If I use a non-existing GUID,
Remove(opportunityproduct, LookUp(opportunityproduct, opportunityproductid = GUID("00000-0000-0000-0000-000d3aacaa23")))
I get the "correct" error that the record does not exist.
Start message: Update, stage=PostOp, etn=opportunityproduct baf25ed5-4693-ee11-be37-000d3aacaa23, ver=1.0.0.0
Exception thrown: Microsoft.Xrm.Sdk.InvalidPluginExecutionException: Error attempting lookup. Entity 'opportunityproduct' With Id = 00000-0000-0000-0000-000d3aacaa23 Does Not Exist
at PowerPlexPlugin.RuleMessageHandler.RunDirect(CompiledExpression[] compiledExpressions, EventMessageName message)
at PowerPlexPlugin.RuleMessageHandler.RunDirect(CompiledExpression compiledExpression, EventMessageName message)
at Microsoft.PowerFx.Evaluator.ExecuteCore(DataverseServices services, PlexPluginContext Context, IOrganizationService orgService)
at Microsoft.PowerFx.Evaluator.<>c__DisplayClass13_0.<Execute>b__0()
So, it seems that in the original code the system did find the record to be deleted, but it does not "want" to delete it through the Plugin...
Does anyone knows what is preventing deleting the record?
best regards,
Koen