Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hi,
I am reading the Id and Name from Api and applying 'LIKE' query filter. I wanted to trim the first 5 letters of Name column from the query applied result. So I further called the infotable datashape service and tried to iterate it but it is returning blank rows. I have mentioned the query I tried. Please help me find what is the issue in it.
var headers = { "Content-Type": "application/json"};
var url = "http://"+ me.host + ":" + me.port + "/api/parametersets";
var Errmsg = "";
var params = {
proxyScheme: undefined /* STRING */,
headers: headers /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: url /* STRING */,
timeout: 15 /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};
try {
var json = Resources["ContentLoaderFunctions"].GetJSON(params);
var errorExist = me.isErrorExist({
errVal: json /* STRING */
});
if ( errorExist == true) {
logger.error( " Error occured while calling get parameter API : " + json);
}
else {
var param1s = {
infoTableName : "InfoTable",
dataShapeName : "FTMParameterSet_DS"
};
var newInfo = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(param1s);
var value = json.array.length;
for(var i = 0; i < json.array.length; i++)
{
if (json.array[i].Id != null && json.array[i].Id !== "" && json.array[i].Id !=" ")
{
if (json.array[i].Name != null )
{
newInfo.AddRow({Id:json.array[i].Id,
Name:json.array[i].Name});
}
}
}
// result1 = newInfo;
var query =
{
"filters":
{
"type": "LIKE",
"fieldName": "Name",
"value": "UI %"
},
};
var params2 = {
t: newInfo/* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
var resultNew = Resources["InfoTableFunctions"].Query(params2);
var param3 = {
infoTableName : "InfoTable",
dataShapeName : "FTMParameterSet_DS"
};
var newInfoNew = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(param3);
for(j = 0; j < resultNew; j++)
{
newInfoNew.AddRow({Id:resultNew.rows[j].Id,
Name:resultNew.rows[j].Name.substring(5)});
}
var result = newInfoNew;
}
}
catch(err)
{
Errmsg = "Exception occured while executing parameter set api";
logger.error("Exception occured while calling get parameter API " + err);
me.getCloseSession();
}
Thanks,
Shalini V.
Solved! Go to Solution.
Hi,
I found out that in final loop I have missed to add length for(j = 0; j < resultNew.length; j++) in for loop. After adding it, it works fine.
Hi,
I found out that in final loop I have missed to add length for(j = 0; j < resultNew.length; j++) in for loop. After adding it, it works fine.