I am writing a plugin which will essentially perform the same function - say, create a task when the status changes. The functionality needs to happen on 2 entities.
Every step is exactly the same except setting of the Entity Type field (an Option Set). This is set to EntityA
or EntityB
depending upon which entity triggered the plugin.
My existing code does the following
new_entitya entityA = (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity && context.PrimaryEntityName == "new_entitya")
? ((Entity)context.InputParameters["Target"]).ToEntity<new_entitya>()
: null;
Now, is there a way that I can set the value of .ToEntity call based on the value of PrimaryEntityName instead of writing new_entitya or new_entityb?