08-03-2023 08:05 AM
Hi,
I am having a table with text list columns.
I have the below expression used on text list column.
@@IIF(Data.Root.ActiveChannelGroup.Channels.Exists("Ch1") ,Data.Root.ActiveChannelGroup.Channels("Ch1").values(1),"NA")
When the conditions satisfies, it gives the value. But when condition fails, instead of "NA", I am getting empty cell.
I am not sure what's wrong with the syntax. please guide me.
08-04-2023 02:40 AM
Hello Durai26,
unfortunately, when using the method IIF, VBS makes it mandatory to always execute the second parameter (but without returning the result), even if the condition is not true. Since the channel does not exist, this causes an error so that the method IIF is aborted and the third parameter is not returned.
To achieve the desired behavior, you can write a user function and call it with @@GetValueFromChannel("Ch1")@@ inside the REPORT table.
Write a VBS function like GetValueFromChannel. Register the VBS file in the dialog for the user commands, so that the function becomes known everywhere in DIAdem and can be used in REPORT.
function GetValueFromChannel(ChannelName)
if Data.Root.ActiveChannelGroup.Channels.Exists(ChannelName) then
GetValueFromChannel = Data.Root.ActiveChannelGroup.Channels(ChannelName).Values(1)
else
GetValueFromChannel = "N/A"
end if
end function
If you want to have the user command permanently available, then save the Desktop.DDD, which contains the references to the user command files.
Regards