Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

CRM 2011 - Custom Workflow RetrieveMultiple Error handler is not working

$
0
0

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


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>