Cannot assign from type 'system.string ' to type 'system.string[]' in assign activity 'assign'

I want to place a string inside an array of strings
Why doesn’t he allow me?

I want processName that is a string to save in processmessags that is string

Hi @mironb

Try this

ProcessMessage={ProcessName}

Cheers!!

Hi @mironb

Try this:

ProcessMessage = Enumerable.Repeat(ProcessName, ProcessMessage.Length).ToArray()

Regards

it depends on the size, init status, prefilled or not of the ProcessMessage String Array
How was ProcessMessage initialized?

Maybe using a String list is more adequate for the case. Afterwards we can also quickly convert myStringListVar.toArray and will get back a StringArray

Hi @mironb

The issue is you are trying to assign a string to array of strings.

Are you trying to loop into a column of processes and need to put all processes into an array of string or one specific process?

@vrdabberu
Why if I add counter to the ProcessMessage it get error and if I remove it its OK ?

Hi @mironb

Can you try the below syntax

ProcessMessage(Counter1)= ProcessName

Regards

1 Like

@mironb
we found a few hints that you want dynamic add /set ProcessName

Variable:
myList | DataType: List(of String) - Default Value: new List(of String)

Adding a ProcessName:
myList = myList.Append(ProcessNameVar).toList

When all is done and finally a string Array is needed:
arrPNames = myList.ToArray()

using the Counter was pasing the right side array under a particular index. So instead of an expected String a String Array was provided from the rigt side to the left side

EDITED:

  • Typo Fixing
  • Screenshot referencing

@vrdabberu

Thank you very much

1 Like

You’re welcome @mironb

Happy Automation

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