1 )Error I am getting:
----------------------
Unexpected exception from plug-in (Execute): IntersystemData.IntersystemData: System.Security.SecurityException: Request failed.
2 )Custom WorkFlow I am using:
-----------------------------------
protected override void Execute(CodeActivityContext executionContext)
{
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
//Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
AdminCrmService = serviceFactory.CreateOrganizationService(null);
try
{
--------------------------
----------------------
-----------------------
tracingService.Trace("Before successful Connection with the target system");
_targetorgservice = TargetInstanceConnection();
tracingService.Trace("Connection successful with the target system");
-------------------------
-------------------------
------------------------
}
}
//TargetInstanceConnection definition
private OrganizationServiceProxy TargetInstanceConnection()
{
OrganizationServiceProxy _service = null;
try
{
ClientCredentials cre = new ClientCredentials();
cre.UserName.UserName = "crmadmin@LTI0001.onmicrosoft.com";
cre.UserName.Password = "Welcome@123";
Uri serviceUri = new Uri("lti0001.crm8.dynamics.com/.../Organization.svc");
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
proxy.EnableProxyTypes();
_service = (OrganizationServiceProxy)proxy;
return _service;
}
catch (Exception ex)
{
throw ex;
}
}