365 On premises
I have crated a workflow which queries an external SQL database and inserts records into a custom crm entity
I am wondering if I can schedule this workflow to execute at 4 specific times in the day rather than manually running it
365 On premises
I have crated a workflow which queries an external SQL database and inserts records into a custom crm entity
I am wondering if I can schedule this workflow to execute at 4 specific times in the day rather than manually running it
Hi,
Can you please try below code to connect to dynamics crm.
public static void ConnectToMSCRM(string UserName, string Password, string SoapOrgServiceUri) { try { ClientCredentials credentials = new ClientCredentials(); credentials.UserName.UserName = UserName; credentials.UserName.Password = Password; Uri serviceUri = new Uri(SoapOrgServiceUri); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, credentials, null); proxy.EnableProxyTypes(); _orgservice = (IOrganizationService)proxy; } catch (Exception ex) { Console.WriteLine("Error while connecting to CRM " ex.Message); Console.ReadKey(); } }
Also, see below github sample code to execute workflow programatically.
Hey Pete,
I think that you could leverage the solution I describe in this post: community.dynamics.com/.../scheduling-recurring-workflows-in-microsoft-dynamics-crm-2011-online-and-on-premise
I know it's old but it still works, trust me.
Hi Roma,
Thank you for your help
Can you explain how to hard code the credentials for domain/user & password
Hi Pete
Let's segregate issues with the code & try to run. Could you please do following and share the results:
1. Hard code credentials for testing purposes & run the console
2. On Workflow Request do this & remove lines 13-15. Execute & test.
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
{
WorkflowId = Guid.Parse("fa69cfbc-f14e-4dfc-a098-d1cd339cac62"),
EntityId = Guid.Parse("566AC746-91E3-EA11-9171-0050560105A7")
};
Do Share the results
Regards
Roma
HI,
Thank you for your reply. I have tried to create a console app using the tutorials, but cannot seem to get it to work.
If I'm right in my understanding then the console App basically acts as if a record was selected and the workflow executed. Based on this understanding I came up with the following code from various posts. The workflow executes a SQL query on a legacy database and creates records in CRM from the results. If i manually run the workflow it works perfectly, however although I'm getting no errors, when running the code below, nothing happens and I don't know where to go from here. Would it be the credentials , should I be using a domain name and password and if so how ?
Sub Main() Try Dim Credentials As ClientCredentials = New ClientCredentials() Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials Dim OrganizationUri As Uri = New Uri("https://xxx.xxxxxxx.co.uk:444/XRMServices/2011/Organization.svc") Dim HomeRealmUri As Uri = Nothing Dim serviceProxy As OrganizationServiceProxy = New OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, Nothing) ' Workflow Guid Dim _workflowId = New Guid("fa69cfbc-f14e-4dfc-a098-d1cd339cac62") ' existing record Guid Dim _entityId = New Guid("566AC746-91E3-EA11-9171-0050560105A7") Dim request As ExecuteWorkflowRequest = New ExecuteWorkflowRequest() With { .WorkflowId = _workflowId, .EntityId = _entityId} Dim response As ExecuteWorkflowResponse = CType(serviceProxy.Execute(request), ExecuteWorkflowResponse) Catch ex As Exception MsgBox(ex.Message.ToString) End Try End Sub
Hi,
One other option is to use bulk delete to schedule your workflow.
more details can be found in below article.
Hi Pete
There is no OOB way to do this. You either move your entire logic to console application and schedule it on task scheduler.
OR, you could make use of configuration entity (custom CRM entity) where all such additional workflows could have your run time marked.
Regards
Roma
There's not a simple way to do this OnPremise. The 2 main options are:
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,409
Most Valuable Professional
nmaenpaa
101,156