Picture of Danilo
Registered 2 years 124 days
Danilo Wednesday, 1 February 2023, 09:33 PM
Put users in groups - JS app
Hi,

I'm trying to add a user to a group and also dynamically remove them from my application.
For this I'm trying to use the PbxTableUsers API, which according to the documentation allows updating user parameters.

I am sending the following message to try to join the user 'danilo.volz' on the group '2000-1':

{"api":"PbxTableUsers","mt":"ReplicateUpdate","columns":{"guid":"8e4b16d1d79840ba980043ea0d9523a3","cn":"Danilo Volz","h323":"danilo.volz","grps":{"name":"2000-1","dyn":"in"},"src":"danilo.volz,inn-lab-ipva"}}

But automatically the group disappears from my profile and I don't join the group either.

Could you indicate if this is the correct way to join and leave groups dynamically? What's wrong with my message?

Thank you very much in advance.
Andreas Fink
Moderator Registered 12 years 277 days
Andreas Fink (innovaphone) Thursday, 2 February 2023, 09:13 PM
Re: Put users in groups - JS app
Hello Danilo,

I see following problems with the JSON:

  • grps - must be an Array
  • src - must be defined in the root object of the JSON message, not inside of the "columns" object


{
"api": "PbxTableUsers",
"mt": "ReplicateUpdate",
"columns": {
"cn": "Danilo Volz",
"grps": {
"dyn": "in",
"name": "2000-1"
},
"guid": "8e4b16d1d79840ba980043ea0d9523a3",
"h323": "danilo.volz",
"src": "danilo.volz,inn-lab-ipva"
},
}


Additionally, in case you want to update only the grps, i would use only guid to identify the object in the ReplicateUpdate message, and do not provide other columns like h323 and cn, if they are not changed.

Best Regards
Andreas Fink
← You can define your color theme preference here