cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Converting array to string

former_member197738
Participant
0 Kudos
5,919

Hi,

I've a variable prompt for Rate_Type based on user selection I'm filtering my measures to show appropriate value.

I am able to capture the value from user prompt selection, but when I'm comparing it, i am getting conversion error, off course due to Array to String.

I tried using "toString" method as mentioned in DeveloperPdf, I don't get any errors in code after that, but it dosent execute { condition }

	var rate_type = Crosstab_Global.getDataSource().getVariableValues("BPC_AMNT_TYPE");
	for (var i = 1; i < rate_type.length; i++) {			
		if (i.toString() === "AT_2") 
		{	
			// apply filter
		} }

Your response is much appreciated, thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

chia-yu_wu
Active Participant

Hi mohd.fahad,

indeed extracting the value you need from the variable value is a little tricky.

Try this:

 switch (rate_type.type) {
 case VariableValueType.Single:
 var singleValue = cast(Type.SingleVariableValue, rate_type);
 console.log(singleValue.value); // you can access the 'value' property now
// apply filter with singleValue
 break;
 case VariableValueType.Multiple:
 var multiValue = cast(Type.MultipleVariableValue, rate_type);
 console.log(multiValue.values); // you can access the 'values' property now
// apply filter with multiValue
 break;
 default:
 break;
}

Hope this helps you out,

Cheers,

Chia-Yu

former_member197738
Participant
0 Kudos

Thanks Yu

Possibly I did something wrong here with CopyPaste code.

Errors

-type - is an unused property

-Single - cannot convert from 'variable value type' to unknown type

-rate_type - invalid argument

former_member197738
Participant

Got it working, I checked against reference guide, I forgot to mark Index