2017-03-08 65 views
0

沒有無效電子郵件和退出電子郵件的篩選器列表我想過濾使用SugarCRM 7 API的Leads和Contact模塊中沒有無效電子郵件和退出電子郵件的列表。使用SugarCRM 7 API

我在參數中添加了以下電子郵件過濾器,但不起作用。如何通過SugarCRM 7.x rest API進行電子郵件過濾。

$filter_arguments = array(

      "filter" => array(

       array(
        "assigned_user_id" => 1, 
       ), 
       array(
        "email1" => array(
         array(
          'opt_out' => array(
           '$equals' => '' 
          ) 
         ) 
        ) 
       ), 
      ), 
     ); 
$url = $base_url . "/Contacts/filter"; 

謝謝。

回答

1

這太多的代碼不會幫你,請檢查:

Reference Link 1

Reference Link 2

下面的例子將演示如何帳務模塊上添加一個預定義的過濾器,返回與所有記錄「客戶」的賬戶類型和「其他」的行業。

要創建預定義的過濾器,請在./custom/Extension/modules/<module>/Ext/Language/中創建顯示標籤擴展名。在這個例子中,我們將創建:

./custom/Extension/modules/Accounts/Ext/Language/en_us.filterAccountByTypeAndIndustry.php 

<?php 

$mod_strings['LBL_FILTER_ACCOUNT_BY_TYPE_AND_INDUSTRY'] = 'Customer/Other Accounts'; 

接下來,創建於./custom/Extension/modules/<module>/Ext/clients/base/filters/basic/.

自定義過濾器擴展在這個例子中,我們將創建:

./custom/Extension/modules/Accounts/Ext/clients/base/filters/basic/filterAccountByTypeAndIndustry.php 

<?php 

$viewdefs['Accounts']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterAccountByTypeAndIndustry', 
    'name' => 'LBL_FILTER_ACCOUNT_BY_TYPE_AND_INDUSTRY', 
    'filter_definition' => array(
     array(
      'account_type' => array(
       '$in' => array(
        'Customer', 
       ), 
      ), 
     ), 
     array(
      'industry' => array(
       '$in' => array(
        'Other', 
       ), 
      ), 
     ), 
    ), 
    'editable' => false, 
    'is_template' => false, 
); 

你應該注意到的是,可編輯和is_template選項已被設置爲「false」。如果可編輯未設置爲「false」,則過濾器將不會顯示在列表視圖過濾器的列表中。

最後,導航到管理>修復,然後點擊「快速修復和重建」來重建擴展,併爲用戶提供預定義的過濾器。 將初始過濾器添加到查找搜索

要添加初始過濾器以記錄查找和輸入提前搜索,請定義過濾器模板。這將允許您在查找父級相關記錄時過濾用戶的結果。以下示例將演示如何在「聯繫人」模塊上爲帳戶查找添加初始過濾器。該初始過濾器將記錄限制爲具有「客戶」的賬戶類型和由聯繫人分配的用戶確定的動態分配的用戶值。

到初始過濾器添加到聯繫人記錄視圖,在./custom/Extension/modules/<module>/Ext/Language/. For this example , we will create:

./custom/Extension/modules/Accounts/Ext/Language/en_us.filterAccountTemplate.php 

<?php 

$mod_strings['LBL_FILTER_ACCOUNT_TEMPLATE'] = 'Customer Accounts By A Dynamic User'; 

接着創建用於過濾器的顯示標籤,在創建一個./custom/Extension/modules/<module>/Ext/clients/base/filters/basic/自定義模板過濾器延伸。 在這個例子中,創建:

./custom/Extension/modules/Accounts/Ext/clients/base/filters/basic/filterAccountTemplate.php 

<?php 

$viewdefs['Accounts']['base']['filter']['basic']['filters'][] = array(
    'id' => 'filterAccountTemplate', 
    'name' => 'LBL_FILTER_ACCOUNT_TEMPLATE', 
    'filter_definition' => array(
     array(
      'account_type' => array(
       '$in' => array(), 
      ), 
     ), 
     array(
      'assigned_user_id' => '' 
     ) 
    ), 
    'editable' => true, 
    'is_template' => true, 
); 

正如你所看到的,filter_definition包含ACCOUNT_TYPE和assigned_user_id陣列。這些過濾器定義將從聯繫人記錄視圖的元數據中接收它們的值。您還應該注意,此過濾器具有is_template並且可編輯設置爲「true」。這是初始過濾器所必需的。

過濾器模板到位後,修改聯繫人記錄視圖的元數據。要完成此操作,請編輯./custom/modules/Contacts/clients/base/views/record/record.php以調整account_name字段。如果此文件在您的本地Sugar安裝中不存在,請導航到管理> Studio>聯繫人>佈局>記錄視圖,然後單擊「保存&部署」以生成該文件。在這個文件中,識別panel_body陣列,如下所示:

1 => 
array (
    'name' => 'panel_body', 
    'label' => 'LBL_RECORD_BODY', 
    'columns' => 2, 
    'labelsOnTop' => true, 
    'placeholders' => true, 
    'newTab' => false, 
    'panelDefault' => 'expanded', 
    'fields' => 
    array (
     0 => 'title', 
     1 => 'phone_mobile', 
     2 => 'department', 
     3 => 'do_not_call', 
     4 => 'account_name', 
     5 => 'email', 
    ), 
), 

接下來,修改ACCOUNT_NAME字段包含所述初始濾波器參數。

1 => 
array (
    'name' => 'panel_body', 
    'label' => 'LBL_RECORD_BODY', 
    'columns' => 2, 
    'labelsOnTop' => true, 
    'placeholders' => true, 
    'newTab' => false, 
    'panelDefault' => 'expanded', 
    'fields' => 
    array (
     0 => 'title', 
     1 => 'phone_mobile', 
     2 => 'department', 
     3 => 'do_not_call', 
     4 => array (
      //field name 
      'name' => 'account_name', 

      //the name of the filter template 
      'initial_filter' => 'filterAccountTemplate', 

      //the display label for users 
      'initial_filter_label' => 'LBL_FILTER_ACCOUNT_TEMPLATE', 



    //the hardcoded filters to pass to the templates filter definition 
      'filter_populate' => array(
       'account_type' => array('Customer') 
      ), 

      //the dynamic filters to pass to the templates filter definition 
      //please note the index of the array will be for the field the data is being pulled from 
      'filter_relate' => array(
       //'field_to_pull_data_from' => 'field_to_populate_data_to' 
       'assigned_user_id' => 'assigned_user_id', 
      ) 
     ), 
     5 => 'email', 
    ), 
), 

最後,導航到管理>修復,然後單擊「快速修復和重建」。這將重建附加信息,並在爲聯繫人選擇父帳戶時爲用戶提供初始過濾器。 從控制器

當創建您自己的看法添加初始過濾器,以抽屜,你可能需要篩選從您的自定義控制器中調用的抽屜裏。使用初始濾波器,如在添加初始過濾器來描述的查找搜索部分中,我們可以通過創建一個過濾器對象和填充config.filter_populate屬性過濾與預定義的值的抽屜如下所示:

//create filter 
var filterOptions = new app.utils.FilterOptions() 
    .config({ 
     'initial_filter': 'filterAccountTemplate', 
     'initial_filter_label': 'LBL_FILTER_ACCOUNT_TEMPLATE', 
     'filter_populate': { 
      'account_type': ['Customer'], 
      'assigned_user_id': 'seed_sally_id' 
     } 
    }) 
    .format(); 

//open drawer 
app.drawer.open({ 
    layout: 'selection-list', 
    context: { 
     module: 'Accounts', 
     filterOptions: filterOptions, 
     parent: this.context 
    } 
}); 

要創建一個帶有動態值的過濾抽屜,創建一個過濾對象,並使用populateRelate方法填充config.filter_relate屬性,如下所示:

//record to filter related fields by 
var contact = app.data.createBean('Contacts', { 
    'first_name': 'John', 
    'last_name': 'Smith',  
    'assigned_user_id': 'seed_sally_id' 
}); 

//create filter 
var filterOptions = new app.utils.FilterOptions() 
    .config({ 
     'initial_filter': 'filterAccountTemplate', 
     'initial_filter_label': 'LBL_FILTER_ACCOUNT_TEMPLATE', 
     'filter_populate': { 
      'account_type': ['Customer'], 
     }, 
     'filter_relate': { 
      'assigned_user_id': 'assigned_user_id' 
     } 
    }) 
    .populateRelate(contact) 
    .format(); 

//open drawer 
app.drawer.open({ 
    layout: 'selection-list', 
    context: { 
     module: 'Accounts', 
     filterOptions: filterOptions, 
     parent: this.context 
    } 
}); 
+0

感謝您的回覆。 –

+0

如果它幫助你,請注意並接受答案。 –