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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Assigning Extra User Extension Properties

ashleyg
1-Newbie

Assigning Extra User Extension Properties

Hi all

I am attempting to assign properties to the User Extensions, I can get the default extensions to be assigned in a script fine. However, when adding extra User Extensions to the UserExtensions ThingShape I cannot assign these in a script.

The following code is what I am using to attempt to do this. The script executes but only the default User Extensions are assigned when I execute the service.

var params = {

  infoTableName : "InfoTable",

  dataShapeName : "Atlas.user.DataShape"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Atlas.user.DataShape)

var userInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

var values = new Object();

values.company = company;

values.emailAddress = Email;

values.firstName = firstName;

values.lastName = secondName;

values.language = Language;

values.mobilePhone = Mobile;

values.continent = continent;

values.country = country;

values.jobTitle = jobTitle;

values.timeZone = timeZone;

values.serialNumberOfCompressor = serialNumberOfCompressor;

values.site = site;

values.UnitsOfMeasurement = UnitsOfMeasurement;

values.regionalCentre = regionalCentre;

userInfoTable.AddRow(values);

var params = {

  values: userInfoTable // INFOTABLE

};

// no return

Users[userName].SetPropertyValues(params);

Any feedback would be greatly appreciated.

Many thanks

Ash

1 ACCEPTED SOLUTION

Accepted Solutions
paic
1-Newbie
(To:ashleyg)

You can just use Users[UserName].UserExtensionName = NewValue;

View solution in original post

3 REPLIES 3
paic
1-Newbie
(To:ashleyg)

You can just use Users[UserName].UserExtensionName = NewValue;

ashleyg
1-Newbie
(To:paic)

Thank you for your suggestion Pai.

After attempting that, the "language" of the user has now successfully changed but none of the other custom User Extensions are being assigned, only firstName, lastName, mobilePhone and emailAddress as before.

This is what my code looks like now (in replace of the SetPropertyValues() function and values object):

    Users[userName].company = company;

    Users[userName].emailAddress = Email;

    Users[userName].firstName = firstName;

    Users[userName].lastName = secondName;

    Users[userName].language = Language;

    Users[userName].mobilePhone = Mobile;

    Users[userName].continent = continent;

    Users[userName].country = country;

    Users[userName].jobTitle = jobTitle;

    Users[userName].timeZone = timeZone;

    Users[userName].serialNumberOfCompressor = serialNumberOfCompressor;

    Users[userName].UnitsOfMeasurement = UnitsOfMeasurement;

    Users[userName].regionalCentre = regionalCentre;

ashleyg
1-Newbie
(To:paic)

Never mind I've just found the solution. The new User Extensions I had added to the UserExtensions ThingShape were not persistent, I didn't think that would matter but after doing that my code now fully works.

Thanks for your help.

Ash

Top Tags