AnsweredAssumed Answered

Get clicked field name in relate.js

Question asked by insxch on Sep 9, 2018
Latest reply on Sep 13, 2018 by insxch

I'm extending a Relate field in Opportunities to apply an initial filter following the directions on:

Applying Initial Filter For Relate Fields and Relationship fields In Sugar 7.x


Adding Initial Filters to Drawers from a Controller

I have it working but want to get the name of the Relate field that was clicked, so I can customize the action in relate.js.


Here's the sample code from the first link that I'm using:

     extendsFrom: 'RelateField',
     initialize: function(options) {
         this._super('initialize', [options]);
     openSelectDrawer: function() {
         var filterOptions = new app.utils.FilterOptions()
             'initial_filter': 'FilterCoursesTemplate',
             'initial_filter_label': 'LBL_FILTER_COURSES_TEMPLATE',
             'filter_populate': {
                 'accounts_courses_accounts_ida': this.model.get('accounts_enrollments_accounts_ida'),
         //this custom code will effect for all relate fields in Enrollment module.But we need initial filter only for Courses relate field.
         filterOptions = (this.getSearchModule() == "Courses") ? filterOptions : this.getFilterOptions();{
             layout: 'selection-list',
             context: {
                 module: this.getSearchModule(),
                 fields: this.getSearchFields(),
                 filterOptions: filterOptions,
         }, _.bind(this.setValue, this));