Hi.
I am new in dynamics crm. i want to create a custom workflow in which i can retrieve all parent accounts against one account.
How can i get this..?
*This post is locked for comments
Using checking and retrieve won't be a good option here instead use fetchxml to fetch all the hierarchial data, keep in mind follow limitation
From SDK
Recursion limits when querying hierarchical data
Because querying hierarchical data can be resource intensive, there is a default limit of 100 recursions allowed conditions for hierarchical queries using the Above, AboveOrEqual, Under, UnderOrEqual, and NotUnder condition operators.
These limits can be adjusted using Windows PowerShell commands through the deployment web service. More information: TechNet: Administer the deployment using Windows PowerShell.
OwnedByMeOrMyReports and OwnedByMeOrMyReportsAndTeams are hierarchical security condition operators that depend on the Hierarchy Depth setting that can be found in Settings > Security > Hierarchy Security. The value of this setting is stored in the Organization.MaxDepthForHierarchicalSecurityModel attribute.
Use Retreivemultiple instead of retrieve and make use of CRM FetchXML hierarchical querying. You can do an "above" or "equal or above" to get all parent accounts.
Refer: exptechsolutions.blogspot.com/.../know-howdynamics-crm-365-query_12.html
Hi Yasir,
You just create one function for,
Entity AccountDetails = service.Retrieve("account", AccountId, new ColumnSet("parentaccountid"));
and return parentaccountid from function.
Do add return value in arraylist. Once the last account not found parentaccount then terminate your code.
Thanks Pravin,
Can you send me some sample code hat how can i do this.....i am new in crm development.
Hi Yasir,
That is the case you can do one thing like, you just store parent account in arraylist until and unless no parent account found.
Regards, Pravin
Suppose Account-1 has parent account Account-2 which has Account-3 as parent account. Account-3’s parent account is Account-4 which has no parent account ..
so i want to retrieve all 3 parent accounts
Hi Yasir,
Please do refer following code as a reference:
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
ITracingService tracingService = executionContext.GetExtension<ITracingService>();
tracingService.Trace("Workflow started");
Guid AccountId = context.PrimaryEntityId;
Entity AccountDetails = service.Retrieve("account", AccountId, new ColumnSet("parentaccountid"));
Using above code you can retrieve parent account lookup details.
Hope this help you.... !!!!
Regards, Pravin
Hello,
Can you provide some details what is your actual requirement ?? why you are looking custom workflow ??
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156