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

TypeError: Cannot call method "AddMember" of null

SOLVED
Highlighted
Amethyst

TypeError: Cannot call method "AddMember" of null

For some reason, my service stopped working.  It used to work, but I think after I duplicated the mashup and started using the duplicate mashup, it stopped working.  When I run the service by itself in the helper Thing, it works.  I get the error when I run it from the mashup.  The bindings are still correct and there seems to be no issue with the service and the inputs to the service.  The input for the user group name comes from the value field of a list.  When I bind the service that populates the list to a grid, the value field is there so it is not "null".  Please see the code below.  It seems that for some reason, the AddMember method is not getting or cannot get the name of the user group entity.

The error message I get is as follows:

 

"User Creation Error: TypeError: Cannot call method "AddMember" of null"

 

I added try/catch since it created a ghost user every time I ran the service from the mashup.

 

********************************************


var params = {
password: Password /* STRING */,
name: UserName /* STRING */,
description: undefined /* STRING */,
tags: undefined /* TAGS */
};

try {

// no return
Resources["EntityServices"].CreateUser(params);

Users[UserName].firstName=FirstName;
Users[UserName].lastName=LastName;
Users[UserName].emailAddress=EmailAddress;
Users[UserName].title=Title;
Users[UserName].workPhone=PhoneNumber;


var newUserParams = {
member: UserName /* STRING */,
type: "User" /* STRING */
};

// no return
Groups[UserRoleGroup].AddMember(newUserParams);

} catch(err) {
logger.debug("User Creation Error: " +err);

}

 

********************************************

 

"UserRoleGroup" contains the name of the user group entity that the user needs to be added to.  UserRoleGroup is a string.

 

I am on Thingworx 8.4.1

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: TypeError: Cannot call method "AddMember" of null

It seems that the Data Shape of service1 (user group list creation service) that feeds the input of service2 (user creation service) was changed at some point and didn't not get re-bound.  It is now working after re-binding the output of service1 to the input of service2. 

3 REPLIES 3

Re: TypeError: Cannot call method "AddMember" of null

Have you recently upgraded your ThingWorx?

Does it still work in the original, non-duplicated mashup?

Re: TypeError: Cannot call method "AddMember" of null

Our Thingworx was recently upgraded, but it was working fine after the upgrade.  The mashup was duplicated after the upgrade.  I still have the original mashup, but the widgets were deleted and replaced with other widgets.

Re: TypeError: Cannot call method "AddMember" of null

It seems that the Data Shape of service1 (user group list creation service) that feeds the input of service2 (user creation service) was changed at some point and didn't not get re-bound.  It is now working after re-binding the output of service1 to the input of service2.