Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Would like to know if the below service can be called to assign members to the user group. I am getting error saying members is null when try to execute it.
/Thingworx/Groups/Sample_Group/Services/AssignMembers.
Can give code snippet for the same?
Solved! Go to Solution.
Hi @SK_9989757
To add multiple users or usergroup
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Principal)
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "Principal"
});
result.AddRow({name: "USER1", type : "User"});
result.AddRow({name: "UUSERGROUP1", type : "Group"});
Groups["USERGROUP"].AssignMembers({
members: result /* INFOTABLE {"dataShape":""} */
});
If you are trying to do this via REST API, your request body should be
{
"members": {
"rows": [
{
"name": "USER1",
"type": "User"
},
{
"name": "UUSERGROUP1",
"type": "Group"
}
],
"dataShape": {
"fieldDefinitions": {
"name": {
"name": "name",
"aspects": {
"isPrimaryKey": true
},
"description": "Principal name",
"baseType": "STRING",
"ordinal": 0
},
"type": {
"name": "type",
"aspects": {
"isPrimaryKey": true
},
"description": "Principal type",
"baseType": "STRING",
"ordinal": 0
}
}
}
}
}
/VR
Groups[<USERGROUP>].AddMember({
member: undefined /* STRING */,
type: undefined /* STRING <-- "User" or "Group" */
});
Hi @SK_9989757
To add multiple users or usergroup
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(Principal)
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "Principal"
});
result.AddRow({name: "USER1", type : "User"});
result.AddRow({name: "UUSERGROUP1", type : "Group"});
Groups["USERGROUP"].AssignMembers({
members: result /* INFOTABLE {"dataShape":""} */
});
If you are trying to do this via REST API, your request body should be
{
"members": {
"rows": [
{
"name": "USER1",
"type": "User"
},
{
"name": "UUSERGROUP1",
"type": "Group"
}
],
"dataShape": {
"fieldDefinitions": {
"name": {
"name": "name",
"aspects": {
"isPrimaryKey": true
},
"description": "Principal name",
"baseType": "STRING",
"ordinal": 0
},
"type": {
"name": "type",
"aspects": {
"isPrimaryKey": true
},
"description": "Principal type",
"baseType": "STRING",
"ordinal": 0
}
}
}
}
}
/VR