Invoking argument / Asset, type text. convert to Array

I added an asset type text, with array format >

For instance:
{“Internal Status”," Function", “LineOfBusiness”, “Training Start Date”, “Training Schedule (hours)”, “Training”, “End Time”}

When invoking the process and getting the asset from the config file (REFramework)

I want to convert the text to an Array

Hi @deni_cr95
When invoking the process and retrieving the asset from the config file within the REFramework, you can follow these steps to access the asset and work with the array of values:

  1. In your Config.xlsx file (or wherever you store your configuration settings), create a new sheet named “Assets” (if it doesn’t exist already).
  2. In the “Assets” sheet, enter the asset name in the first column (e.g., “AssetName”) and the array of values in the second column. Each value should be separated by a comma.
  3. In the REFramework, locate the “Get Asset” state in the Init state or any other appropriate location where you want to retrieve the asset.
  4. Add an “Assign” activity after the “Get Asset” state to extract the array of values from the asset.Assign: assetArray = config("AssetName").ToString().Split(","c)Here, assetArray is a variable of type Array of String that will store the individual values from the asset.
  5. You can now access each value of the asset by indexing the assetArray variable. For example, to retrieve the first value, use assetArray(0). To retrieve the second value, use assetArray(1), and so on.Example: internalStatus = assetArray(0)Here, internalStatus is a variable that will store the value of the first element in the asset array.
1 Like

To get Asset from Orchestrator you can modify step 4
First Get Asset value and store in variable type string.
After that split that variable and pass to array

When the string is as above we would recommend to change to:

["Internal Status"," Function", "LineOfBusiness", "Training Start Date", "Training Schedule (hours)", "Training", "End Time"]

it’s a JSON String of a serialized Array and can be deserialized by

Newtonsoft.Json.JsonConvert.DeserializeObject(Of String())(in_Config("YourKey").toString.Trim)

Or change string to: in_Config("YourKey").toString.Trim.Split(","c)

"Internal Status,Function,LineOfBusiness,Training Start Date,Training Schedule (hours),Training,End Time"

and split it by:

1 Like

Hi @deni_cr95
another brief solution:

  1. Drag and drop an “Assign” activity to your workflow.
  2. Create a string variable to store the asset value, for example, assetValue.
  3. Assign the asset value to the variable using the Get Asset activity. Provide the asset name and assign the output to assetValue.
  4. Drag and drop another “Assign” activity below the previous one.
  5. Create an array variable to store the split values, for example, splitArray.
  6. Split the assetValue using the desired delimiter using the Split function. Assign the result to splitArray. Assign: splitArray = assetValue.Split(","c) Note: Replace the delimiter “,” with your desired separator.
  7. Now you can use the splitArray variable to access the individual values in your automation workflow.

This is dangerous as it will fail if one of the values has a , in it.

Format your string as…

[‘Internal Status’,‘Function’,‘LineOfBusiness’]

Then use Deserialize JSON Array to convert it to a JArray.

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