I have an expression rule will return 2 types of record type
- Case
- Error
depends on if there is any error occur during the expression rule process
so when I get the result from the expression rule, I do need to know what type is the returned value,
how can I achieve that?
I tried to use typeof(), but it does not work. I am wondering if I need to use type!, but I do not know how to write a valid reference using type!
Discussion posts and replies are publicly visible
What exactly does not work with typeof?
I have an expression rule, in the expression rule I call an integration to GET data from an external API. so it is possible API request failed due to network issue or server down. if it is succeeded, it should return a list of Case instances (a list of record types), but if it fail, it will return an instance of Error (one single record type)
So from the caller that calling the expression rule, I need to identify if the instances returns are list of Cases or a single Error, then I can write to database accordingly
I suggest to always return a map that includes a boolean "success" field and a field "data" that holds the actual data.
Thank you, that solves the problem. But I am just curious, is there a way I can do such comparison?
Sure. See below code:
a!localVariables( local!recordData: { 'recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee'('recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee.fields.{4424ccce-aeb2-49e1-b28f-07099a8476ed}id':1), 'recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee'('recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee.fields.{4424ccce-aeb2-49e1-b28f-07099a8476ed}id':2), 'recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee'('recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee.fields.{4424ccce-aeb2-49e1-b28f-07099a8476ed}id':3), }, a!map( type: typeof(local!recordData), typeName: typename(typeof(local!recordData)), compare: typeof(local!recordData) = a!listType('recordType!{ad927cfe-f590-436e-a37f-9a73818be10a}AAD Attendee') ) )