I've tested the below code for a button and it works..
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/28.0/apex.js")} var a = "{!$Setup.TestH__c.EnabledH__c}"; //TestH__c--> Custom setting API Name, EnabledH__c-->Field API Name, Custom Setting Type: Hierarchy alert('This is Cust Setting>> '+a);
If your's is still not working post your code and let me know what kind of custom setting you are using.
Hi, This below code working for update hierarchy type custom setting by javascript button.
{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js") } {!REQUIRESCRIPT("/soap/ajax/40.0/apex.js") } sforce.connection.sessionId = "{!$Api.Session_ID}"; var userId = '{!$User.Id}'; // it's provide current user var query = sforce.connection.query("select id from Scholarship_Detail__c where SetupOwnerId ='"+ userId+"'"); // customSetting var recordId = query.getArray("records"); if(recordId.length > 0){ var i = recordId[0].Id; } var Scholarship_Detail_obj =new sforce.SObject("Scholarship_Detail__c"); var Scholarship = new sforce.SObject('Scholarship__c'); Scholarship.Id = '{!Scholarship__c.Id}'; Scholarship_Detail_obj.id = i; Scholarship_Detail_obj.SetupOwnerId = userId; Scholarship_Detail_obj.Scholarship_Id__c = '{!Scholarship__c.Id}'; var result = sforce.connection.update([Scholarship_Detail_obj]);
and if you want to create custom setting than use below line var result = sforce.connection.create([Scholarship_Detail_obj]);
See if this helps
http://help.salesforce.com/apex/HTViewSolution?id=000003862&language=en_US
Hi Sam,
i need to call them and use them in my Java script button logic. When i use as mentioned in the above link, It says Merge field not valid
I've tested the below code for a button and it works..
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/28.0/apex.js")}
var a = "{!$Setup.TestH__c.EnabledH__c}"; //TestH__c--> Custom setting API Name, EnabledH__c-->Field API Name, Custom Setting Type: Hierarchy
alert('This is Cust Setting>> '+a);
If your's is still not working post your code and let me know what kind of custom setting you are using.
Hi Sam,
i have the following custo setting created
CustomAPi Name: Docusignmsg__c
Field1 name:Email_message__c
Field2name: Text_Subject__c
i am using list type
{!REQUIRESCRIPT("/soap/ajax/28.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/28.0/apex.js")}
var result = sforce.connection.query("Select Name, Email_message__c,Text_Subject__c from Docusignmsg__c");
records = result.getArray("records");
for (var i=0; i< records.length; i++) {
alert('List Setting Name@@@ ' + records[i].Name);
alert('List Setting Email_message__c@@@ ' + records[i].Email_message__c);
alert('List Setting Text_Subject__c @@@ ' + records[i].Text_Subject__c );
}
This below code working for update hierarchy type custom setting by javascript button.
{!REQUIRESCRIPT("/soap/ajax/40.0/connection.js") }
{!REQUIRESCRIPT("/soap/ajax/40.0/apex.js") }
sforce.connection.sessionId = "{!$Api.Session_ID}";
var userId = '{!$User.Id}'; // it's provide current user
var query = sforce.connection.query("select id from Scholarship_Detail__c where SetupOwnerId ='"+ userId+"'"); // customSetting
var recordId = query.getArray("records");
if(recordId.length > 0){
var i = recordId[0].Id;
}
var Scholarship_Detail_obj =new sforce.SObject("Scholarship_Detail__c");
var Scholarship = new sforce.SObject('Scholarship__c');
Scholarship.Id = '{!Scholarship__c.Id}';
Scholarship_Detail_obj.id = i;
Scholarship_Detail_obj.SetupOwnerId = userId;
Scholarship_Detail_obj.Scholarship_Id__c = '{!Scholarship__c.Id}';
var result = sforce.connection.update([Scholarship_Detail_obj]);
and if you want to create custom setting than use below line
var result = sforce.connection.create([Scholarship_Detail_obj]);