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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to increment a value in a infotable for creation of a geofence on map?

Bhargav1
6-Contributor

How to increment a value in a infotable for creation of a geofence on map?

Hello ,

 I created a geofence using an infotable inside an infotable,i.e (outer infotable as columns id and location ,column location contains one more infotable along with columns again id and location region.).The location region column is with location base type and id has a GUID as base type.I need to increment a id value in outer infotable. So that I can close the geo fence set. Service as  follows :

region = me.map_regionCopy;
if(!region) {
params = {
infoTableName : "InfoTable",
dataShapeName : "Region"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Region)
region = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
}

//var result = region;
var params = {
infoTableName : "InfoTable",
dataShapeName : "shape_for_geo1"
};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(shape_for_geo1)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
var newEntry = new Object();
//var i,n = 1;

for ( var i=1 in result.rows){
newEntry.LocationRegion = region; // INFOTABLE
newEntry.ID = i; // NUMBER [Primary Key]
// break;

i++

}


result.AddRow(newEntry);

 

But this is giving output as null infotable with column names where I can't see the data in infotable.

 

Thanks,

Bhargav.

 

ACCEPTED SOLUTION

Accepted Solutions

Hi,

 

Please check this code:

 

var params = {
infoTableName : "InfoTable",
dataShapeName : "location"
};
location1 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
location1.AddRow( { id:"1", loc:"west" });
location1.AddRow( { id:"2", loc:"north" });
//logger.warn(" no of rows of location : "+location1.length);
var params1 = {
infoTableName : "InfoTable",
dataShapeName : "region"
};

var res = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params1);
res.AddRow({ id:1, location:location1});

var result=res;

 

It is creating a nested infotable with 1 row that contains an id and an infotable location.

raluca_edu_0-1581596902517.png

 

Please use the above example for your requirement (my region datashape contains fields: id and location of type infotable).

 

Hope it helps,

Raluca Edu

 

View solution in original post

4 REPLIES 4

Hi,

 

Please use the following for instead of yours and adjust the values as you need (I don't like that you use i++ in a for loop):

 

for(var i = 0; i < result.length; i++) {
newEntry.LocationRegion = region; // INFOTABLE
newEntry.ID = i; // NUMBER [Primary Key]
}

Hope it helps,

Raluca Edu

 

Bhargav1
6-Contributor
(To:raluca_edu)

Hello Raluca Edu,

  I tried the for loop suggested by you in my service, but still, the output is null, same as shown in the previous attachment.

 

Can you suggest me any other way or is there any problem in my code.

 

Thanks,

Bhargav.

Hi,

 

Please check this code:

 

var params = {
infoTableName : "InfoTable",
dataShapeName : "location"
};
location1 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
location1.AddRow( { id:"1", loc:"west" });
location1.AddRow( { id:"2", loc:"north" });
//logger.warn(" no of rows of location : "+location1.length);
var params1 = {
infoTableName : "InfoTable",
dataShapeName : "region"
};

var res = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params1);
res.AddRow({ id:1, location:location1});

var result=res;

 

It is creating a nested infotable with 1 row that contains an id and an infotable location.

raluca_edu_0-1581596902517.png

 

Please use the above example for your requirement (my region datashape contains fields: id and location of type infotable).

 

Hope it helps,

Raluca Edu

 

slangley
23-Emerald II
(To:Bhargav1)

Hi @Bhargav1.

 

If one of the previous replies answered your question, please mark the appropriate one as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Announcements


Top Tags