How to remove a team via REST API?

Hi everyone.

I'm trying to remove a team via the Rest API but am having problems with doing so. As far as I can tell the "correct" endpoint would be https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_12.0/Integration/Web_Services/REST_API/Endpoints/modulerecordlinklink_nameremote_id_DELETE/.

However when trying the following:

URL/.../3b029990-4ed8-11ed-8fd3-00163ef40625

I'm getting 500 error with the logs showing:
PHP Recoverable fatal error:  Object of class Team could not be converted to string in /modules/Teams/TeamSetLink.php on line 294

Has anyone been able to remove teams via this API or could share any thoughts? I noticed the documenation around ACL roles and team_sets isn't great for the Rest API so  any help would be great.


Thanks,


Daniel

Parents
  • Hello 

    The endpoint that you shared works if you want to remove a user from a Team. 

    For example, if I need to remove Sally( id:seed_sally_id) from the West (id:West) team my endpoint would look like this: 

    DELETE: mysugarurl/rest/v11/Teams/West/link/users/seed_sally_id

    If what you are trying to accomplish is to remove a team from a given record, the best is to replicate what Sugar does in GUI.

    Instead of deleting you will be Updating the record with the new Teams.


    As an example if you want to update an Opportunity keeping only the West team the Endpoint will look like this: 

    PUT: mysugarurl/rest/v11/Opportunities/43f1c38e-1e0c-11ed-a55a-02a5a97c2d5e

    Body: {"team_name":[{"id":"West","name":"West","name_2":"","primary":true,"selected":false}]}

     

    I hope this helps. 

    André

     

  • Hi . Thinking about it, if my account record had West and East, and I wanted to just remove East, how would I do that via the API? So not replace just remove.

  • Hi 

    When you remove a team via GUI, what Sugar is doing is replacing the team_set_id for that record.
    The new Team Set will have the team combination without the team you removed. 

    Therefore via API, the most straightforward approach would be

    1 - Retrieve the teams from the Account Record (West and East)

    2 - Process the team list to remove the teams you want to remove (Remove East)

    3 - Update the record with the reduced team list it was described before. (Update with team West)

    This will update the team set id with the new team list. 

    If you want to remove a given team from a team set, the only way that crosses my mind is to load the team's relationship to get the team_set_id and then use the remove()method. 
    But that needs to be done Programmatically as it is described here

Reply
  • Hi 

    When you remove a team via GUI, what Sugar is doing is replacing the team_set_id for that record.
    The new Team Set will have the team combination without the team you removed. 

    Therefore via API, the most straightforward approach would be

    1 - Retrieve the teams from the Account Record (West and East)

    2 - Process the team list to remove the teams you want to remove (Remove East)

    3 - Update the record with the reduced team list it was described before. (Update with team West)

    This will update the team set id with the new team list. 

    If you want to remove a given team from a team set, the only way that crosses my mind is to load the team's relationship to get the team_set_id and then use the remove()method. 
    But that needs to be done Programmatically as it is described here

Children
No Data