cancel
Showing results for 
Search instead for 
Did you mean: 
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for 
Search instead for 
Did you mean: 

TypeError: Cannot call method "ServiceName" of null

psp316r
14-Alexandrite

TypeError: Cannot call method "ServiceName" of null

In a Thing, Made an Service Testing2, In this calling a Service(AddAlertEntry) from DataTable, when this is executed normally/Individually works fine.

When the same service(Testing2) is called from an subscription for every 15mins gives the following error:

 

 

Error in: Test_Thing.Testing2 javascript service. Message ::TypeError: Cannot call method "AddAlertEntry" of null (Testing2#1)

 

 

AddAlertEntry Code:

 

 

logger.warn(Code+ " " + Asset+ " " + Time+ " " + Alerts+ " " + Priority+ " " + Status+ " " + AlertDuration+ " " + UserInformation+ " " + Resolved);

var values = me.CreateValues();
values.Code = Code;
values.Asset = Asset;
values.Time =Time;
values.Alerts = Alerts;
values.Priority = Priority;
values.Status = Status;
values.AlertDuration = AlertDuration;
values.UserInformation = "Shashi";
values.Resolved = me.GetMaxID()+1;
var params = {
    values: values,
};
var result = Things["ActiveAlert_DataTable"].AddDataTableEntry(params);

 

 

 @paic  @slangley @c_lowy 

Thanks,
Shashi

1 ACCEPTED SOLUTION

Accepted Solutions
psp316r
14-Alexandrite
(To:psp316r)

Hi,

Found the issue, it is because no proper permissions were not given to the DataTable that was used in the Code, When permissions given, it got fixed.

Thanks,
Shashi

View solution in original post

2 REPLIES 2
bchaudhary
12-Amethyst
(To:psp316r)

Hi @psp316r 

 

Can you enable Debug level logging and share the error you are getting in Script logs?

Goto subsystem>>loggingsubsystem>>Configuration>> check enable Stacktracing and try to reproduce the scenario.

You can also add loggers to find the point of failure.

Regards

Bhawna

psp316r
14-Alexandrite
(To:psp316r)

Hi,

Found the issue, it is because no proper permissions were not given to the DataTable that was used in the Code, When permissions given, it got fixed.

Thanks,
Shashi

View solution in original post

Announcements