Hi Friends
Can you please help me to create on demand custom workflow.
This should run once everyday on demand.
*This post is locked for comments
Hi Friends
Can you please help me to create on demand custom workflow.
This should run once everyday on demand.
*This post is locked for comments
Hi Suchisuchi,
You could refer the below code to retrieve the root account reference by passing the main account. This is built in console application but you should be able to use the same code in plugin or custom workflow activity.
public void UpdateAccountParent() { using (service = new OrganizationServiceProxy(new Uri(_organizationURI), null, _credential, null)) { var entityId = new Guid("E32B12C4-7F95-E811-A961-000D3AE05E81"); var entityName = "account"; var mainAccount = SearchHelper.RetrieveSingle(service, entityName, entityId); // Get the root accoutn reference EntityReference rootAccountRef = null; GetRootAccount(service, mainAccount.ToEntityReference(), out rootAccountRef); // If root account ref is null that means there is no parent account, displaying the name from the main account if (rootAccountRef != null) { var rootAccount = service.Retrieve(rootAccountRef.LogicalName, rootAccountRef.Id, new ColumnSet(true)); Console.WriteLine(rootAccount["name"]); } else { Console.WriteLine(mainAccount["name"]); } } } public void GetRootAccount(IOrganizationService service, EntityReference accountRef, out EntityReference rootAccount) { rootAccount = null; // Check if the account has parent var accoutnRecord = service.Retrieve(accountRef.LogicalName, accountRef.Id, new ColumnSet(true)); if (accoutnRecord.Contains("parentaccountid")) { var parentAccountRef = (EntityReference)accoutnRecord["parentaccountid"]; GetRootAccount(service, parentAccountRef, out rootAccount); } else { rootAccount = accountRef; } }
Hope this helps.
You can't schedule a workflow within Dynamics 365 but you can do it within a Microsoft flow thatcrmblog.wordpress.com/.../scheduling-workflows-with-microsoft-flow will show you how to do that and also how to update a records from within that flow...
I dont need plugin but custom workflow that will be calling the on demand workflow..
Further more, you don't even need a plugin to update the fields, you could achie this in out of box workflow (real time)
oh Ok, let me try the suggestion then, and will update. Thanks Ravi
Hi Suchisuchi,
The logic to update the records should be same as mentioned community.dynamics.com/.../289465
What exactly you are looking for?
Also, as mentioned above, you don't need to run it daily on the modified account, you can simply update the record when the account update. Is there something more to this requirement?
Hope this helps.
Hi Ravi, It is actual requirement this time :(
Account Name: Account A
PAL: PAL A
ParentAccount Id= Account B
Account Name: Account B
PAL: PAL B
ParentAccount Id= PAL C
Account Name: Account C
PAL: PAL C
ParentAccount Id=
In this example, Account A's Parent account is "Account B" and "Account B's" parent is "Account C". Acccount C does not have a parentAccount Id so it is the top level Account for Account A and Account B.
So for Account A, aac_toplevepal= PAL C and aac_toplevelpalname=Account C
So for Account B, aac_toplevepal= PAL C and aac_toplevelpalname=Account C
So for Account C, aac_toplevepal= PAL C and aac_toplevelpalname=Account C
We have to run this workflow everynight once a day. It should get all accounts that were modified yesterday and update their xcv_toplevelpal and xcv_toplevelpalname using the above logic.
Hi Suchisuchi,
Could you please share your requirement in more detail? Is this an actual requirement or you want to learn more about custom workflows?
If you want to update the parent account name to another field on the account record then you don't need a custom workflow and certainly you don't need to run it on daily basis. You could simply write a real time workflow which triggers on update and the retrieves the parent account name and populate your field.
Hope this helps.
Here it is re-uploaded
Hi Suchisuchi,
Please reupload the image.png file.
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,436
Most Valuable Professional
nmaenpaa
101,156