Why are my promoted variables are not shared between Workshop modules in Carbon?

99 Views Asked by At

I have a carbon workspace with two workshop modules. One of them includes a button that opens another workshop module and should pass a promoted variable (an array) to the new module. But when the second module is opened via the button it looks like the variable was never passed along.

1

There are 1 best solutions below

0
On BEST ANSWER

In the network tab it should show an error like the below:

foundry.objects.workshop.app.workshopModuleParameters: Tried passing a list parameter when opening another Workshop module in Carbon, but list parameters are not currently supported by Carbon, so ignoring the parameter value

In that case there are two options, one is to move to non-array variables if possible:

Change Type

The other one is to use a function that would take the array, convert it into a string with a specific delimiter and pass this string variable to the new module:

 @Function()
    public makeString(arrayToConvert: string[]): string{
        var convertedString = arrayToConvert[0];

        if(arrayToConvert.length===1){
            return convertedString
        }

        for (let i =1; i<arrayToConvert.length; i++){
            convertedString = convertedString.concat(",", arrayToConvert[i])      
        }

        return convertedString;
    }   

Convert the array to a string with a variable:

convert to string

And pass the string variable to the new module:

pass variable to new module

In the second module the string would be converted back into an array.

  @Function()
    public makeArray(stringToConvert: string): string[]{
        var convertedArray = stringToConvert.split(",");

        return convertedArray;
    }

revert to array