cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass multiple values in parameter for data action via scripting API

azm_azm
Participant
0 Kudos
1,190

Hi,

Here is the scenario. There are three different model as Model A, Model B and Model C. Model A has dimension called Region and it has no hierarchy. Model B also has the same dimension as Region but has a parent child hierarchy. Model C has a dimension as Region and it has no hierarchy. Region dimension is private dimension across three different model.

My requirement is to read the values from Model A. Based on these values, I have to copy the data from Model B to Model C. Values that I read from Model A are always the leaf members of the hierarchy in Model B.

I have written the script logic to read the values from Model 'A' and even pass these values as parameters in the cross model copy data action to copy from Model 'B' to Model 'C' but I'm getting validation error message when I'm executing the script. Below is script logic I'm using in my story.

 

var A = Atable.getDataSource.getMembers("Region",100);

var key = Array.Utils.create(Type.String);

 for (var i = 0 ; i <A.length ; i++)

{

key.push(A[i].id);

}

DataAction.setParameterValue("Region",key);  //This line doesn't give me any error but I can see the validation issue on the data action job monitor. SAC is not exactly specifying the reason behind this validation error.

DataAction.setParameterValue("Region",["[Region].[H1].&["+ key[1]+"]" , "[Region].[H1].&["+ key[2]+"]" ]); // When I'm executing this script, it is working fine as I'm able to pass single/ multiple values using this syntax.

The highlighted script above is hard coded and it runs without any validation errors. Is there a way that I can pass multiple values for this parameter which has a hierarchy defined. Anyone who has faced this similar issue or knows the workaround in this case. Their comments would be deeply appreciated.

Thanks

 

View Entire Topic
N1kh1l
Active Contributor

@azm_azm 

The setParameterValue method of DataAction accepts string or array of string as parameter value. So if you want to pass multiple values you can just pass the array of strings rather multiple single values.

setParameterValue(id: string, value: string | string[] | DataActionParameterValue JSON | number): void

 

Just create an array where the members are stored with Hierarchy information. Or try changing the Region parameter of this DA to Hierrachy  "any" and see if it works.

 

Hope this helps !!

Nikhil

azm_azm
Participant
0 Kudos
Thank you for your reply Nikhil. I tried changing the Region parameter to "Any" Hierarchy but it seems like I was still getting the same validation error. When I stored the array of strings with Hierarchy information, it worked for me.