Skip to main content
19-Tanzanite
August 8, 2023
Solved

How to add/update UserSessionShapes in User Management Subsystem programmatically

  • August 8, 2023
  • 1 reply
  • 937 views

Hi,

 

How to add UserSessionShapes in User Management Subsystem programmatically.

 

I'm using the below code to update it 

// table: INFOTABLE dataShape: ""
let data = Subsystems["UserManagementSubsystem"].GetConfigurationTable({
 tableName: "UserSessionShapes" /* STRING */
});

// Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
let query = {
 "filters": {
 "type": "And",
 "filters": [{
 "fieldName": "name",
 "type": "EQ",
 "value": "MYSHAPE"
 }]
 }
};
 
let params = {
 t: data /* INFOTABLE */ ,
 query: query /* QUERY */
};

// result: INFOTABLE
let sessionData = Resources["InfoTableFunctions"].Query(params);

if (sessionData.length === 0) {
 data.AddRow({
 "name": "MYSHAPE"
 });
 Subsystems["UserManagementSubsystem"].SetConfigurationTableRows({
 values: data /* INFOTABLE */,
 persistent: true /* BOOLEAN {"defaultValue":true} */,
 tableName: "UserSessionShapes" /* STRING */
 });
}
var result = data;

 

When I execute the code I'm getting this error 

 

UserSessionShapes does not have a primary key field assigned - See Script Error Log for more details.

 

The above script works with the normal thing configuration Table. 

 

Please help me with this. Thanks in advance.

 

/VR

 

Best answer by Arun_C

Hi @Velkumar ,

 

Im not sure about the SetConfigurationTableRows serivce in UserMananagemnetSubsytem why it's not as same with other.

If you want to add Session Shapes in UsermanagentSubsytem in programatically better to use the service - AddSessionShape. It may help you.

 

Subsystems["UserManagementSubsystem"].AddSessionShape({
	name: 'MYSHAPENAME' /* THINGSHAPENAME */
});

 

 

Thanks & Regards,

Arun C

1 reply

Arun_C16-PearlAnswer
16-Pearl
August 9, 2023

Hi @Velkumar ,

 

Im not sure about the SetConfigurationTableRows serivce in UserMananagemnetSubsytem why it's not as same with other.

If you want to add Session Shapes in UsermanagentSubsytem in programatically better to use the service - AddSessionShape. It may help you.

 

Subsystems["UserManagementSubsystem"].AddSessionShape({
	name: 'MYSHAPENAME' /* THINGSHAPENAME */
});

 

 

Thanks & Regards,

Arun C

Velkumar19-TanzaniteAuthor
19-Tanzanite
August 9, 2023

Thanks @Arun_C  this helps.