Google Appmaker - 在 PeopleViewer 模板中按 PrimaryOrganizationTitle 搜索人员

Google Appmaker - Search people by PrimaryOrganizationTitle in the PeopleViewer template

我正在处理 peopleViewer 模板,我想知道如何修改搜索选项以按 post 和姓名查找人员。

我试过添加:
userInfoDs.query.filters.PrimaryOrganizationTitle = title;在 loadAllData() 函数中,但是

1- 自动完成不在过滤器中显示 PrimaryOrganizationTitle
2- 我认为 var title = userInfoDs.query.parameters.PrimaryOrganizationTitle; 不会创建变量。

编辑:或者,我想知道是否可以手动添加要在 userInfoDs.query.filters 中使用的过滤器。

您引用的数据源 userInfoDs 用于加载有关 found/selected/current 用户(People 页面)的数据。 SearchResults 页面使用 SearchResults 数据源。页眉中的搜索框绑定到 keywords. Directory Model's keywords would look for search term occurrences in First/Last Names and Primary Email. Directory Model doesn't support filtering by PrimaryOrganizationTitle: https://developers.google.com/appmaker/models/directory#user_fields_and_query_operators

因此,如果您急切地想通过目录模型不支持的字段搜索人员,您别无选择,只能使用 Admin Directory SDK。这是您的服务器端搜索脚本的大概味道。

/**
 * Searches for people.
 */
function search(term) {
  var result = AdminDirectory.Users.list({
    domain: 'ENTER HERE YOUR DOMAIN (exapmle.com)',
    // Build your query basing on this doc
    // https://developers.google.com/admin-sdk/directory/v1/guides/search-users
    query: getQuery(term),
    viewType: 'domain_public',
    maxResults: 10
  });

  return mapToAppMakerRecords(result);
}

此处 getQuery 函数应构建类似于 email:Bob or name:Bob or orgTitle:Bob 的查询,mapToAppMakerRecords 应将搜索结果转换为 App Maker UI 可以消化的形式(Calculated Model or a follow up query to Directory Model).使用这种方法,与结果排序和分页相关的所有工作也将落在您的肩上。