function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mateo AlcauterMateo Alcauter 

How to call a custom field on javascript

I'm creating a custom button using onclick javascript. I have called the custom object that i'm working with, but i'm unable to call any custom fields of this custom object. I highlited the line that is not working properly. 

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var records = {!GETRECORDIDS($ObjectType.Transaction__c)}; 
var strIDs=''; 
if (records[0] == null) 

alert('Please select a record'); 

else 

for (var n=0; n<records.length; n++) 

strIDs = records[n]; 
alert(strIDs.Total_Fee__c); 

alert('Success'); 
}
Best Answer chosen by Mateo Alcauter
sfdcMonkey.comsfdcMonkey.com
hi mateo,
check the below link for sample code :

https://developer.salesforce.com/forums/?id=906F00000008rtUIAQ
check last reply of Zachary Alexander 30

i hope it helps you.
 Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 

All Answers

sfdcMonkey.comsfdcMonkey.com
hi mateo,
check the below link for sample code :

https://developer.salesforce.com/forums/?id=906F00000008rtUIAQ
check last reply of Zachary Alexander 30

i hope it helps you.
 Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper solution for others
thanks 
sfdcmonkey.com 
This was selected as the best answer
Mateo AlcauterMateo Alcauter
I've updated it, but still not woking. what am i missing

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} 

var result = {!GETRECORDIDS($ObjectType.Transaction__c)}; 
var cycleTransactions = new Array(); 
var myquery = ('SELECT Id, Submit_for_Approval__c FROM Transaction__c WHERE Id in (\'' + result.join('\',\'') + '\')' ); 
var queryResults = sforce.connection.query(myquery); 
var records = queryResults.getArray("records"); 

if (records == null) 

alert('Please select a record'); 

else 

for (var n=0; n<records.length; n++) 

alert(queryResults.records[n].Id); 
queryResults.records[n].Id.Submit_for_Approval__c = true; 

alert('Success'); 
}
Mateo AlcauterMateo Alcauter
if i put this alert(queryResults.records[n]); 
I get this
{type:'Transaction__c', Id:'a065B000002YO2xQAG', Submit_for_Approval__c:'false', }
Mateo AlcauterMateo Alcauter
nvm got it