Skip to main content
16-Pearl
October 12, 2022
Solved

Wrapped java.lang.NullPointerException

  • October 12, 2022
  • 1 reply
  • 2737 views

Below is my code:

 

//creating an infotable

let Log = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "DataShape"
});

 

//Defining date variable

var currentDate;

 

//assigning valueList variable to my infoTable property that contains values (current it only has one row)

var valuesList = Things["TestThing1"].infoTableThingProperty;

 

//loop through the infotable above
for(var i=0; i<valuesList.length; i++){

// new object 
newEntry = {
duration:valuesList[i].duration,
source: valuesList[i].Source,
Name: valuesList[i].Name,
Type: valuesList[i].Type,
StartTime: valuesList[i].StartTime,
EndTime: valuesList[i].faultEndTime,
Voltage: valuesList[i].Voltage,
Text: valuesList[i].Text

};

//adding my object values to the infotable
Log.AddRow(newEntry);
}

 

//adding my infotable to the stream 

var newLog = Things["SinkWorx.PwrSupplyError_Stream"].AddStreamEntries({
values: Log /* INFOTABLE {"dataShape":"StreamEntryWithValues"} */
});

 

//output result

let result = Log;

 

I keep getting the error above, I am not sure why.

Does anyone know how I can fix it?

 

Kind Regards,

TB

Best answer by Sathishkumar_C

 

 

duration: valuesList[i].duration,
source: valuesList[i].Source,
Name: valuesList[i].Name,
Type: valuesList[i].Type,
StartTime: valuesList[i].StartTime,
EndTime: valuesList[i].faultEndTime,
Voltage: valuesList[i].Voltage,
Text: valuesList[i].Text

 

 

Any o these INTEGER/NUMBER values might by NULL.

 

Try only with STRING values and change accordingly

1 reply

17-Peridot
October 12, 2022

try this..

//creating an infotable
let streamEntryData = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
	infoTableName: "InfoTable",
	dataShapeName: "StreamEntryWithValues"
});
//Defining date variable
var currentDate;
//assigning valueList variable to my infoTable property that contains values (current it only has one row)

var valuesList = Things["TestThing1"].infoTableThingProperty;

//loop through the infotable above
for (var i = 0; i < valuesList.length; i++) {
 let Log = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
 infoTableName: "InfoTable",
 dataShapeName: "DataShape"
 });
	// new object 
	newEntry = {
		duration: valuesList[i].duration,
		source: valuesList[i].Source,
		Name: valuesList[i].Name,
		Type: valuesList[i].Type,
		StartTime: valuesList[i].StartTime,
		EndTime: valuesList[i].faultEndTime,
		Voltage: valuesList[i].Voltage,
		Text: valuesList[i].Text

	};
	//adding my object values to the infotable
	Log.AddRow(newEntry);
 
 // StreamEntryWithValues entry object
 let streamEntry = {
 sourceType: undefined,// STRING
 values: Log,// INFOTABLE
 location: undefined,// LOCATION
 source: undefined,// STRING
 tags: undefined,// TAGS
 timestamp: new Date()// DATETIME
 };
	streamEntryData.AddRow(newEntry);
}

//adding my infotable to the stream 
var newLog = Things["SinkWorx.PwrSupplyError_Stream"].AddStreamEntries({
	values: streamEntryData /* INFOTABLE {"dataShape":"StreamEntryWithValues"} */
});

//output result
let result = streamEntryData;
Janicen16-PearlAuthor
16-Pearl
October 12, 2022

Hi @Sathishkumar_C  thank you for the suggestion but I am still getting the same error.

 

17-Peridot
October 12, 2022

 

 

duration: valuesList[i].duration,
source: valuesList[i].Source,
Name: valuesList[i].Name,
Type: valuesList[i].Type,
StartTime: valuesList[i].StartTime,
EndTime: valuesList[i].faultEndTime,
Voltage: valuesList[i].Voltage,
Text: valuesList[i].Text

 

 

Any o these INTEGER/NUMBER values might by NULL.

 

Try only with STRING values and change accordingly