You need to sign in to do that
Don't have an account?
Manoj Dega
Urgent Issue on Custom Settings
I've a Custom Settings with Hierarchy, on that two fields Read__c, Unread__c.
The Above Code Snippet Works Good. when we Use Custom Settings Value in not works.
integer i=10; integer j=5; query1='select id,name,is_read__c,(select id from Attachments where createddate < last_n_days :'+i+') from Account where is_read__C = false'; query2='select id,name,is_read__c,(select id from Attachments where createddate < last_n_days :'+j+') from Account where is_read__C = true';
The Above Code Snippet Works Good. when we Use Custom Settings Value in not works.
AccountSetting__c acs =AccountSetting__c.getInstance(); integer i=integer.valueOf(acs.Read__c); //Read = 10 integer j=integer.valueOf(acs.Unread__c); //Unread = 20 query1='select id,name,is_read__c,(select id from Attachments where createddate < last_n_days :'+i+') from Account where is_read__C = false'; query2='select id,name,is_read__c,(select id from Attachments where createddate < last_n_days :'+j+') from Account where is_read__C = true';Thanks in Advance
If you have defined the values for "Read__c" and "Unread__c" inside "Default Organization Level Value" under Hierarchical Custom Setting; then you will have to use getOrgDefaults() method.
so your code will be
AccountSetting__c acs = AccountSetting__c.getOrgDefaults();
Hope this resolves your issue.
All Answers
If you have defined the values for "Read__c" and "Unread__c" inside "Default Organization Level Value" under Hierarchical Custom Setting; then you will have to use getOrgDefaults() method.
so your code will be
AccountSetting__c acs = AccountSetting__c.getOrgDefaults();
Hope this resolves your issue.