Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. IOrganizationService _service;
  2.  
  3. public void Execute(IServiceProvider serviceprovider)
  4. {
  5. IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));
  6. IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));
  7. IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
  8.  
  9. if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
  10. {
  11.  
  12. Entity ent = (Entity)context.InputParameters["Target"];
  13.  
  14. if (ent.LogicalName != "opportunity")
  15. return;
  16.  
  17. string connstring = @"Url=https://mlptcare.crm5.dynamics.com; Username=Jaya@mlptcare.onmicrosoft.com; Password=CrmAdmin365; authtype=Office365";
  18. CrmServiceClient conn = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(connstring);
  19. service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient :
  20.  
  21. (IOrganizationService)conn.OrganizationServiceProxy;
  22.  
  23.  
  24. try
  25. {
  26. Guid fabercastel = new Guid("efd566dc-10ff-e511-80df-c4346bdcddc1");
  27. Entity _account = new Entity("account");
  28. _account = service.Retrieve(_account.LogicalName, fabercastel, new ColumnSet("name"));
  29.  
  30. string x = _account["name"].ToString();
  31.  
  32.  
  33. throw new InvalidPluginExecutionException("Result of Query : " + x);
  34. }
  35. catch (Exception ex)
  36. {
  37. throw new InvalidPluginExecutionException(ex.Message);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement