Assign a Transaction from the queue if its not null

Hi,

I am reading data from the queue, but I want to check if its null or not and then assign it.
I can use and If statement with a condition like this:
in_TransactionItem.SpecificContent.Any(Function(x) x.Key = “WorkflowInstanceID” AndAlso x.Value IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(x.Value.ToString))

But I want to write it in a single assign, without using IF,
How can I do that?
Thanks

Hi @chauhan.rachita30

Try the below syntax:

workflowInstanceID = If(in_TransactionItem.SpecificContent.Any(Function(x) x.Key = "WorkflowInstanceID" AndAlso x.Value IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(x.Value.ToString)),in_TransactionItem.SpecificContent("WorkflowInstanceID").ToString, Nothing)

Regards

1 Like

@chauhan.rachita30

Please try this

workflowInstanceID = If(in_TransactionItem.SpecificContent.Any(Function(x) x.Key = "WorkflowInstanceID" AndAlso x.Value IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(x.Value.ToString)), in_TransactionItem.SpecificContent("WorkflowInstanceID").ToString,Nothing)

Cheers

1 Like

Hi @chauhan.rachita30

Try this

If(in_TransactionItem.SpecificContent.ContainsKey("WorkflowInstanceID") AndAlso in_TransactionItem.SpecificContent("WorkflowInstanceID") IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(in_TransactionItem.SpecificContent("WorkflowInstanceID").ToString), in_TransactionItem.SpecificContent("WorkflowInstanceID").ToString, String.Empty)

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.