Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IOrganizationService _service;
- public void Execute(IServiceProvider serviceprovider)
- {
- IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));
- IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));
- IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
- if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
- {
- Entity ent = (Entity)context.InputParameters["Target"];
- if (ent.LogicalName != "opportunity")
- return;
- string connstring = @"Url=https://mlptcare.crm5.dynamics.com; Username=Jaya@mlptcare.onmicrosoft.com; Password=CrmAdmin365; authtype=Office365";
- CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connstring);
- service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient :
- (IOrganizationService)conn.OrganizationServiceProxy;
- try
- {
- Guid fabercastel = new Guid("efd566dc-10ff-e511-80df-c4346bdcddc1");
- Entity _account = new Entity("account");
- _account = service.Retrieve(_account.LogicalName, fabercastel, new ColumnSet("name"));
- string x = _account["name"].ToString();
- throw new InvalidPluginExecutionException("Result of Query : " + x);
- }
- catch (Exception ex)
- {
- throw new InvalidPluginExecutionException(ex.Message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement