C# Expressions in template

Status
Not open for further replies.

railkos

Free User
Joined
Nov 10, 2017
Messages
2
Reaction score
0
Hi,

[[CallStartTimeLocal].AddHours([HoursFix]).ToString("yyyy-MM-dd HH:mm:ss.fff")]

This expression throws an error System.NullReferenceException at TcxLexicalParser.LexEvaluator.InstanceFunction

[[CallStartTimeLocal].AddHours(1).ToString("yyyy-MM-dd HH:mm:ss.fff")] works nomally

Any ideas how to fix, or another way to add custom time from "Parameters"?
 
Hello @railkos,

Using the parameter there will not work due to the way the expression is evaluated.

If you have only a few options, for example 1, 2 and 3, then maybe you can use conditionals. For example, to send a value using conditionals you would do something like this:
Instead of:
XML:
<Value Key="call_date_time">[[CallStartTimeLocal].AddHours([HoursFix]).ToString("yyyy-MM-dd HH:mm:ss.fff")]</Value>

You should use:
XML:
<Value Key="call_date_time" If="[HoursFix]==1">[[CallStartTimeLocal].AddHours(1).ToString("yyyy-MM-dd HH:mm:ss.fff")]</Value>
<Value Key="call_date_time" If="[HoursFix]==2">[[CallStartTimeLocal].AddHours(2).ToString("yyyy-MM-dd HH:mm:ss.fff")]</Value>
<Value Key="call_date_time" If="[HoursFix]==3">[[CallStartTimeLocal].AddHours(3).ToString("yyyy-MM-dd HH:mm:ss.fff")]</Value>

You can add 24 lines like that if you want, or just the values that you consider valid...
 
Status
Not open for further replies.

Latest Posts

Forum statistics

Threads
112,324
Messages
591,897
Members
165,475
Latest member
lastshadow