我创建了一个具有两个字段的自定义设置对象。我还创建了一个Apex控制器和一个Visual Force Page来更新/编辑自定义设置。作为系统管理员,我可以使用该表单编辑自定义设置。但是当我以标准用户身份登录时,表单字段没有显示。当我以标准用户身份登录时,即使通过Setup-> Develop-> CustomSettings并单击“管理”,我也无法添加自定义设置。我已经使控制器和Visual Force页面权限都可以被任何人访问。

以下是我的控制器代码,

   public class XYZSettingsController
     {
     public  XYZSettings__c mySettings {get; set;}
     public XYZSettings__c myOrgSettings{get; set;}

     public XYZSettingsController()
        {

          mySettings = XYZSettings__c.getValues(System.Userinfo.getUserId());
          myOrgSettings = XYZSettings__c.getInstance();
            if(mySettings == null)
              {
              mySettings = new XYZSettings__c(SetupOwnerId=System.Userinfo.getUserId());
              }

         }
    public String getOrgUrl()
    {
    return   myOrgSettings.XYZ_Url__c;
    }

    public String getOrgEmail()
    {
            return   myOrgSettings.XYZ_Email__c;
    }

    public String getUrl()
    {
            return   mySettings.XYZ_Url__c;
    }

    public String getEmail()
    {

           return   mySettings.XYZ_Email__c;
    }

    public PageReference save() {

      if(mySettings.id == null){
           upsert mySettings;
             }
      else{
           update mySettings;
             }
      return null;
    }
    }


下面是我的Visual Force页面,

<apex:page Controller="XYZSettingsController" title="Edit XYZ access settings">
  <apex:form >
    <apex:pagemessage severity="info" strength="1">
     Your default XYZ platform url is: {!OrgUrl} and Email is: {!OrgEmail}
     <br></br>
      You can override it in the settings below
    </apex:pagemessage>
   <apex:pageBlock title="Edit XYZ settings" mode="edit">
  <apex:commandButton action="{!save}" value="Save"/>
     <apex:pageBlockSection columns="2">
            <apex:inputField value="{!mySettings.XYZ_Url__c}"/>
            <apex:inputField value="{!mySettings.XYZ_Email__c}"/>
    </apex:pageBlockSection>
   </apex:pageBlock>
 </apex:form>
</apex:page>


有什么线索吗?

最佳答案

我只是遇到了这个问题,并在Salesforce上做了回答。请参考我的答案以解决此问题。 https://salesforce.stackexchange.com/questions/28329/giving-users-access-to-a-specific-custom-setting-without-granting-them-customize/45079#45079

09-25 20:14