I created a custom settings object with two fields. I also created an Apex controller and a Visual Force page to update / change user settings. As a system administrator, I can edit user settings using this form. But when I log in as a standard user, the form fields are not displayed. I canβt add custom settings even through Setup-> Develop-> CustomSettings and click on the control when I am registered as a standard user. I have allowed access for both my controller and Visual Force.
Below is my controller code,
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; } }
And below is my Visual Force page,
<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>
Any clues?
source share