Skip to content

Instantly share code, notes, and snippets.

@pawelgradecki
Created April 14, 2017 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelgradecki/1d35a16a5d2c1e02d9c31f02f6d2f431 to your computer and use it in GitHub Desktop.
Save pawelgradecki/1d35a16a5d2c1e02d9c31f02f6d2f431 to your computer and use it in GitHub Desktop.
Using Interface in plugins
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 entityWithTotalSum = context.InputParameters["Target"] as IEntityWithTotalSum;
entityWithTotalSum.new_totalsum = entityWithTotalSum.new_netamount + entityWithTotalSum.new_margin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment