迭代自定义列表设置并返回所有条目

Iterate over custom list setting and return all entries

本文关键字:返回 自定义 列表 设置 迭代      更新时间:2023-09-26

如果我有一个Salesforce自定义列表设置,'Info_List__c'带有一个字段,'Info_Field__c'.

一个遍历列表并返回所有条目的方法是什么样子的呢?

我如何从VF页面调用该方法并将结果存储在JS对象中?

In controller

global with sharing class Ctrl{
@RemoteAction
global static List<String> getList(){
  List<String> result = new List<String>();
  List<Info_List__c> lst = [Select Info_Field__c from Info_List__c];
  for(Info_List__c lstObj : lst){
    result.add(lstObj.Info_Field__c);
  }
  return result;
}
}

在JS端

var strArr = Ctrl.getList();

如果你有名称空间,它将是(例如NS)

var strArr = NS.Ctrl.getList();