How to use createMembers method in planning model API?

586 views Asked by At

I am trying to add members to a planning model from a SAC analytics application and when trying to do so I am getting this error: TypeError: e.startsWith is not a function

Here is the code where I am trying to add the members to the planning model:

for(var i=0; i<Ar_ID.length; i++) {
    idx = idx + 1;
    InventoryPlanning = ({id: idx, description: '', properties: {Amount: Ar_AMOUNT[i], Comment: Ar_COMMENTS[i], Company_Code: Ar_COMPANY_CODE[i], Country_Code: Ar_COUNTRY_CODE[i], Currency_Info: Ar_CURRENCY[i], Date: Ar_DATE[i], Lock_Flag: Ar_LOCK_FLAG[i], Type: Ar_TYPE[i], Value_Date: Ar_VALUE_DATE[i]}});
    var result= PlanningModel_1.createMembers("Inventory",InventoryPlanning);
    console.log(result);
}

When I print what InventoryPlanning(which is a script variable of PlanningModelMember type) looks like this is the output: enter image description here

This is what I would want, and matches the properties in the Inventory dimension, so I am unsure why the createMembers method is giving me this error.

1

There are 1 answers

0
AJHello On BEST ANSWER

The solution ended up being to cast the idx variable to a string, storing it in a temporary variable, and putting the temporary variable as the id key like so:

for(var i=0; i<Ar_ID.length; i++) {
    idx = idx + 1;
    var tmp=ConvertUtils.numberToString(idx);
    InventoryPlanning = ({id: tmp, description: '', properties: {Amount: Ar_AMOUNT[i], Comment: Ar_COMMENTS[i], Company_Code: Ar_COMPANY_CODE[i], Country_Code: Ar_COUNTRY_CODE[i], Currency_Info: Ar_CURRENCY[i], Date: Ar_DATE[i], Lock_Flag: Ar_LOCK_FLAG[i], Type: Ar_TYPE[i], Value_Date: Ar_VALUE_DATE[i]}});
    var result= PlanningModel_1.createMembers("Inventory",InventoryPlanning);
    console.log(result);
}