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
AdiviAdivi 

scontrol using AJAX toolkit

I created an scontrol using the AJAX tookit... It was able to query the database for me and tell me exactly how many records existed... This was done by doing something like

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
var accName = "{!Account_Name}";
var queryResult = sforceClient.Query("select billingcity, id from account where Name=\'"+accName+"\'");
if(queryResult.size == 1)
{
var account = queryResult.records[0];
alert("Billing City is: " + account.billingcity+"\nID = " + account.id);
}

But the program was giving an error at the alert line saying that "billingcity is null or not an object".

Can anyone help me on this.. Thanks
DevAngelDevAngel
Hi Adivi,

The way to access the fields on a record is by using the get and set functions of the record.

In you sample it should be account.get("billingcity");
AdiviAdivi
But in the document on working with AJAX toolkit, it says that account.billingcity is fine too...
AdiviAdivi
Dave
When I was trying to access the casenumber as mentioned by you after quering the case table like this

alert(cases.get("casenumber"));

This was the error
Line:60
Char:8
Code:0
Error:'undefined' is null or not an object
URL:https://tapp0.salesforce.com/servlet/servlet.Integration?lid=01NT000000002Pt&eid=500T0000000TqvM&enc=UTF-8
Ron HessRon Hess
you really could have an empty billing city, your code does not appear to check for that.