ttajic
3/18/2016 - 4:16 PM

Inspect Workflow Errors

Inspect Workflow Errors

select asyncoperation0.asyncoperationid as asyncoperationid, 
asyncoperation0.name as name,
asyncoperation0.regardingobjectidname as regardingobjectidname, 
asyncoperation0.operationtypename as operationtypename,
asyncoperation0.statuscodename as statuscodename, 
asyncoperation0.owneridname as owneridname,
convert(date,asyncoperation0.startedon,123) as startedon,
asyncoperation0.statecodename as statecodename, 
convert(date, asyncoperation0.createdon,123) as createdon,
asyncoperation0.errorcode,
[message],
waitingreason = case 
	when asyncoperation0.errorcode = -2147204784 then 'SQL error'
    when asyncoperation0.errorcode = -2147220946 then 'Cannot updated closed record'
    when asyncoperation0.errorcode = -2147187962 then 'CRM permissions issue'
    when asyncoperation0.errorcode = -2147218688 then 'Object address not found or party maked as non-emailable'            
    when asyncoperation0.errorcode = -2147220969 then 'Record to be changed no longer exists'           
    when asyncoperation0.errorcode = -2147204303 then 'Maximum field length exceeded'
    when asyncoperation0.errorcode = -2147220970 then 'Cannot access file – file in use'
    when asyncoperation0.errorcode = -2147201001 then 'Request timed out'
    when asyncoperation0.errorcode = -2147204718 then 'Invalid email address for send email'                         
    else '<Unknown>'
    end
from FilteredAsyncOperation as asyncoperation0
where (asyncoperation0.recurrencestarttimeutc is null and asyncoperation0.statuscode = 10)
and asyncoperation0.errorcode is not null
and asyncoperation0.errorcode   = -2147218688            
/*and case                                            when asyncoperation0.errorcode = -2147204784 then 'SQL error'

                                                                        when asyncoperation0.errorcode = -2147220946 then 'Cannot updated closed record'

                                                                        when asyncoperation0.errorcode = -2147187962 then 'CRM permissions issue'

                                                                        when asyncoperation0.errorcode = -2147218688 then 'Object address not found or party maked as non-emailable'            

                                                                        when asyncoperation0.errorcode = -2147220969 then 'Record to be changed no longer exists'           

                                                                        when asyncoperation0.errorcode = -2147204303 then 'Maximum field length exceeded'

                                                                        when asyncoperation0.errorcode = -2147220970 then 'Cannot access file – file in use'

                                                                        when asyncoperation0.errorcode = -2147201001 then 'Request timed out'           

                                                                        when asyncoperation0.errorcode = -2147204718 then 'Invalid email address for send email'                         

                                                                        else '<Unknown>'

                                                end = '<Unknown>'*/
order by 
asyncoperation0.startedon desc, 
asyncoperation0.asyncoperationid asc