Set selected_teams (padlock) in Logic Hook

Hello All,

I am working on 

SugarCRM Enterprise, Version 9.0.2 (Build 191) (Spring '19)

I can set padlock (which is used for teams with special access: O&ST) from record.js but I want to set it from hook.

I want to achieve same functionality from before_save logic hook. Anybody having any idea?

Help highly appreciated.

I done with following code in record.js 

({

    extendsFrom: 'RecordView',

    initialize: function (options) {
        this._super('initialize', [options]);
    },
     
     handleSave: function() {
          
          var selected_team = this.model.attributes.custom_status_c;
          
          var ele = new Array();
          
          this.model.attributes.team_name.forEach(function(element, index){
               if(element.name == selected_team){
                    element.selected = true;
               } else {
                    element.selected = false;
               }
               ele.push(element);
          });
          
          this.model.set('team_name', ele);          
          
          this._super('handleSave');
     },
})
  • This is my code for adding teams, I use constants to hold the IDs of the teams.

    $teamSetBean = new TeamSet();
    $relatedTeams = $teamSetBean->getTeams($accessBean->team_set_id);
    $teams_arr = array_keys($relatedTeams);
    $teams_arr[] = IT_TEAM;
    $teams_arr[] = CRM_ADMIN_TEAM;
    $taskBean->load_relationship('teams');
    $taskBean->team_id = $accessBean->team_id;
    $taskBean->teams->replace(array_unique($teams_arr));
    $taskBean->save(false);
  • Kenneth Brill: Thanks for the code.

    But I need to implement "selected team" feature which will activate after "Team Level Access" for any module.

    I got the solution later on.
    I am sharing it here.

    // $aclTeams contains array of Team Ids.

    $teamSetBean = new TeamSet();
    $teamSetId = $teamSetBean->addTeams($aclTeams);

    // $caseBean is bean of Cases module.
    $caseBean->acl_team_set_id = $teamSetId;

    My requirement of setting Padlock programatically (opened lock shown in image), for additional access to the records.

    I found this code in documentation. Here is the link. https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.1/Architecture/Teams/Manipulating_Tea… 

    Setting Padlock