web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans