How to write expressions in AE

I am trying to write a expression List.Add(value) in assign activity, Getting error “Expression does not produce a value”

Kindly help me how to add values to list

Hi @taeeb
Follow below steps to create string list

  1. Create a list argument
  2. Argument Name - list
  3. Argument Type - System.Collection.Generic.List<system.string>
  4. Drag and drop Assign activity
  5. To - list
  6. Expression - new List(of string)(new string(){“Pune”,“Mumbai”,“Delhi”,“Varanasi”})
    Done

Hi bhuvan,

Tq for the solution.
How to add value in list. Can you please provide the syntaxes for add the value to list and how to retrieve values from that list.

Regards,
AMD Taeeb

Hi @taeeb
Steps to retrieve value from list

  1. Create two argument - counter and listsize as int32
  2. Assign Activity To - listsize and expression - list.Count
  3. Advance loop activity - select N-Iteration
  4. Click on gear icon to configure advance loop and select listsize in No. Of Iteration drop down
  5. Within advance loop - WriteList activity text - list(counter)
  6. Within advance loop - Assign Activity To - counter and expression - counter+1

Regards,
Bhuvan Pandey

Hi Bhuvan,

Can you please share steps to add the values to the list

Regards,
AMD Taeeb

Hi,

Assign activity do not support complex data structures. Only String/ Boolean / Int / Double and Date data type are supported.

Regards,
Amit

Hi,

Is there any alternate solution for adding values to list?

Regards,
AMD Taeeb

@taeeb

There’s a solution to make this work. Use Powershell!

Create a string argument. let’s say MyList. Initialize its value to “$list=‘Sample1’, ‘Sample 2’, ‘Sample 3’”
to add more values to the list concatenate it by “,‘New Value’”.

And then you can perform the powershell operation on list.

like if you want to check if your list contains ‘Sample 1’, then

join your list in the string format along with the powershell command to check it.

Example - “$list=‘Sample1’, ‘Sample 2’, ‘Sample 3’”+argumentWhichcontainsNewlineCharacter+"$list -contains ‘Sample 1’"

This will return True.

Let me know if this works for you. Ping me in case it doesn’t work.