Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM 2011 - Custom Workflow RetrieveMultiple Error handler is not working

(0) ShareShare
ReportReport
Posted on by

Hi 

I have a Custom Workflow , which performs lot of tasks  and if any task fails then I need to update a ErrorLog Entity, but if “RetrieveMultiple” method is failed, any Try/Catch block is not catching the error message.

What is the wrong in my code ? I purposefully make the “RetrieveMultiple” failed by passing a wrong “valuetoFetch” value to test this.

Execution pipe-->CustomWorkflow's Execute Method()-->ProcessData()--> getEntityMethod()  

If getEntityMethod is failed then I need to pass the error message back to the originating call “CustomWorkflow Execute Method” where I am writing into the ErrrorLog entity

sample code is


CustomWorkflow()
{
Execute()
try
{
ProcessData(); 
}
catch (Exception ex)
{
// update the ErrorLog entity with all the error messages

 UpdateErrorLogEntity();
}

 

ProcessData()

{

try
{
getEntityMethod(); 
}
catch (Exception ex)
{
throw ex;
}

}


getEntityMethod()
{
try
{
QueryByAttribute query = new QueryByAttribute();
query.ColumnSet = new ColumnSet(true);
query.EntityName = entityName;
query.Attributes.AddRange(attributeToFetch);
query.Values.AddRange(valuetoFetch);

EntityCollection myEntities = service.RetrieveMultiple(query);

if (myEntities.Entities.Count > 0)
{
myEntity = myEntities.Entities[0];
}
else
{

throw new Exception("getEntityMethod - No Records found");
}
}
catch (System.Exception ex)

throw ex;
}
}
}

Any help would be appreciated.

MSK

*This post is locked for comments

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans