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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Returning 4 rows of value in a single column using array

svisveswaraiya
17-Peridot

Returning 4 rows of value in a single column using array

Hi,

I am trying to return 4 values in a single column using java script. I have created a datashape to store the values and using array. But the script doesnt accept the infotable and says can not convert json to infotable. When I keep the base type as json it doesnt return anything the result is blank. 

How can I return 4 rows in single column? Please help me in modifying the service.

 

var params = {
infoTableName: "FilterBy" /* STRING */,
dataShapeName: "Navistar_FilterBy_DS" /* DATASHAPENAME */
};
var FilterBy = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var arrayOfFilters = [5];


{
FilterBy.Filters = ["Part", "LineSet", "Job Num", "Part Type"];

for( i = 0; i < FilterBy.length; i++)
{
arrayOfFilters = [i];
}

}
result = arrayOfFilters;

 

 

Thanks,

Shalini V.

3 REPLIES 3

Hello,

 

You need to be more specific about what exactly you want to do, how you're going to use those values, etc. Depending on that you will use different approaches, for example:

 

1. Return an INFOTABLE with the list of filter criteria ("Filters" field is a STRING here)

var FilterBy = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

FilterBy.AddRow({ Filters: "Part" });
FilterBy.AddRow({ Filters: "LineSet" });
FilterBy.AddRow({ Filters: "Job Num" });
FilterBy.AddRow({ Filters: "Part Type" });

result = FilterBy;

 

2. Return a list of filter criteria for each row ("Filters" is an INFOTABLE here)

var FilterBy = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var FilterCriteria = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({ ... another datashape ... });

FilterCriteria.AddRow({ name: "Part" });
FilterCriteria.AddRow({ name: "LineSet" });
FilterCriteria.AddRow({ name: "Job Num" });
FilterCriteria.AddRow({ name: "Part Type" });

FilterBy.AddRow({ Filters: FilterCriteria });
result = FilterBy;

 

3. Return a list of filter criteria for each row ("Filters" is a JSON with array here)

var FilterBy = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

FilterBy.AddRow({ Filters: { names: [
"Part",
"LineSet",
"Job Num",
"Part Type"
] } });

result = FilterBy;

 

Option 1 is most probably what you really want.

 

Regards,
Constantine

Hi @Constantine ,

Thanks for your swift response. When I try to execute these services am getting error like, params is not defined. Could you please help me on what I am missing. And I wanted to return the output as infotable as I am going to bind it to a combo box. 

 

Thanks,

Shalini V.

Use params from the snippet you provided in your first message.
Top Tags