Created
April 14, 2017 12:35
-
-
Save pawelgradecki/931c111bebfc20c32628d72ca751da57 to your computer and use it in GitHub Desktop.
Late bound plugin run on multiple entities
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CalculateTotalAmountLateBoundPlugin : IPlugin | |
{ | |
public void Execute(IServiceProvider serviceProvider) | |
{ | |
var context = serviceProvider.GetService(typeof(IPluginExecutionContext)) as IPluginExecutionContext; | |
var serviceFactory = serviceProvider.GetService(typeof(IOrganizationServiceFactory)) as IOrganizationServiceFactory; | |
var service = serviceFactory.CreateOrganizationService(context.UserId); | |
var lateBoundEntity = context.InputParameters["Target"] as Entity; | |
lateBoundEntity["new_totalsum"] = lateBoundEntity.GetAttributeValue<decimal>("new_netamount") + lateBoundEntity.GetAttributeValue<decimal>("new_margin"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment