CRM wizard, IF condition with CallEstablishedTimeUTC field

nicojmb2

Silver Partner
Advanced Certified
Joined
Feb 2, 2023
Messages
81
Reaction score
19
Hi,

I'm playing with CRM wizard template, and i've a problem when [CallEstablishedTimeUTC] varible is null.

How i can condition to not send this variable if it's null.

I tried this but do not work.

<Value Key="CallEstablishedTimeUTC" If="[CallEstablishedTimeUTC]!=Null" Passes="0" Type="String">[[CallEstablishedTimeUTC].ToString("yyyy-MM-ddTHH:mm:ssZ")]</Value>

and in the logs show this error:

2024/09/27 15:15:18.295|0022|Erro| CRM: Exception during call reporting: System.NullReferenceException: Object reference not set to an instance of an object.
at TcxLexicalParser.LexEvaluator.InstanceFunction(IValueManager valueManager, FunctionElement functionElement)
at TcxLexicalParser.LexEvaluator.ProcessInt(FunctionElement functionElement, IValueManager valueManager)
at Integration.Crm.Engine.ScenarioProcessorBase.CreateJsonFromPostValues(RequestItem requestItem, IValueManager customManager)
at Integration.Crm.Engine.ScenarioProcessorBase.ProcessRequest(ScenarioRequest request, IValueManager customManager, HttpClient client, CancellationToken token)
at Integration.Crm.Engine.ScenarioProcessorBase.ProcessScenario(ProtocolScenario scenario, IValueManager customManager, SqlQueryParameter[] sqlQueryParameter, CancellationToken token)
at Integration.Crm.Engine.ScenarioProcessorBase.Execute(ProtocolScenario scenario, SqlQueryParameter[] sqlQueryParameter, CancellationToken token)
at Integration.Crm.Engine.CrmProcessor.ExecuteScenarioByName(String scenarioName, IEnumerable`1 parameters, Boolean useNoAuthProvider, CancellationToken token)
at Integration.Crm.Engine.CrmProcessor.ExecuteScenarioWithRetries(String scenarioId, Dictionary`2 parameters, CancellationToken token)
at Integration.Crm.Engine.CrmProcessor.ReportCall(CallEndedEvent callEndedEvent, CancellationToken token)

Regards!
 
Try this:

If="[[CallEstablishedTimeUTC].ToString(&quot;yyyy-MM-ddTHH:mm:ssZ&quot;)]!=&quot;0000-00-00 T00:00:00Z&quot;"
 
Try this:

If="[[CallEstablishedTimeUTC].ToString(&quot;yyyy-MM-ddTHH:mm:ssZ&quot;)]!=&quot;0000-00-00 T00:00:00Z&quot;"

Same error :(.

I think the problem is that the variable CallEstablishedTimeUTC is null, so when passing it to a string it gives an NullRefernceException error.

This only happens when I make an outgoing call and they don't respond.
 
Yeah, the established time isn't always there for many reasons. I would avoid it if I were you.

@edossantos_sipcaller may know how to conditionally include it.
 
When the call is not established, the variable [CallEstablishedTimeUTC] is not set at all, so you can't check it.

However, in that case you have the [CallEstablishedTimeUTCMillis] set to -1, so you could use:
If="[CallEstablishedTimeUTCMillis]!=-1"
 
When the call is not established, the variable [CallEstablishedTimeUTC] is not set at all, so you can't check it.

However, in that case you have the [CallEstablishedTimeUTCMillis] set to -1, so you could use:
If="[CallEstablishedTimeUTCMillis]!=-1"
Thanks, with -1 works perfect.