fake-xrm-easy icon indicating copy to clipboard operation
fake-xrm-easy copied to clipboard

Execute Plugin Steps

Open SteveDrakey opened this issue 7 years ago • 8 comments

Is it possible to register plugin steps and have them execute on the creation of records?

eg, create contact and have the fake CRM call any pre / post steps during the update.

Thanks

SteveDrakey avatar May 19 '17 11:05 SteveDrakey

Hi Steve,

Nope, at the minute. The intention was to unit tests plugins independently from each other, but not to do something like , .Update(contact) and then also run the pre / post plugins registered for the Update message.

But, you can inject the output parameters from one plugin into another one via the context. What are you trying to achieve / what's your vision?

jordimontana82 avatar May 19 '17 15:05 jordimontana82

Thanks for the reply.

We have the od integration test that should really be unit tests with a mocked up CRM, some of these expect data in fields to be populated by plugins.

-- ps

typing with a broken hand so apologies for being brief.

SteveDrakey avatar May 19 '17 16:05 SteveDrakey

Hi @SteveDrakey, Does my PR solve your question?

eNeRGy164 avatar Aug 09 '17 06:08 eNeRGy164

Hi @SteveDrakey ,

This issue has been open for a while.... does the new UsePipelineSimulation introduced by @eNeRGy164 solve your question now?

jordimontana82 avatar Sep 05 '18 22:09 jordimontana82

Not sure if this is the right place to ask this question. I have been trying out UsePipelineSimulation, however some of our existing code expects OrganizationName to be not null on the IExecutionContext. When using ExecutePluginWith, we can specify properties on the XrmFakedPluginExecutionContext, but it doesn't seem possible when using UsePipelineSimulation. Is there anyway of setting up the execution context with UsePipelineSimulation?

rcjorgensen avatar Nov 09 '18 08:11 rcjorgensen

@rcjorgensen could you please provide a sample unit test that the community could use to reproduce the OrgName issue please?

jordimontana82 avatar Jan 22 '20 21:01 jordimontana82

Worth adding the possibility of registering images as well...

Example: Synchronizing some value(s) from contact to a referenced entity and all of the other contacts that also has the same reference.

Therefore i have to compare the old values (PreImage) with the new data (PostImage) to not make endless updates between them.

public void UpdatePerson(ICrmContext context, contact postImage, contact preImage)
{
   if (preImage.JobTitle != postImage.JobTitle)
   {
	   new_person updatePerson = new new_person()
	   {
		   Id = postImage.new_personid.Id
		   new_jobtitle = postImage.JobTitle
	   };

	   context.CrmService.Update(updatePerson);
   }

}

Best way would be to extend the function "RegisterPluginStep" von the context with an additional parameter for images (Name, ProcessingStepImageType - already existing in code, attributes).

jordimontana82 avatar Jan 22 '20 22:01 jordimontana82

This is now part of this issue @psengeis :)

It would be amazing if you have the the time to issue a PR ?

jordimontana82 avatar Jan 22 '20 22:01 jordimontana82