You need to sign in to do that
Don't have an account?
zstomeh
Expected Object
I copied the syntax below from the API samples and made a little change to read an existing field , which it did , but when reading a custom field id failed.
Please help.
========================
<html>
<head>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<head>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script>
function setupPage() {
//function contains all code to execute after page is rendered
function setupPage() {
//function contains all code to execute after page is rendered
var state = { //state that you need when the callback is called
output : document.getElementById("output"),
startTime : new Date().getTime()};
output : document.getElementById("output"),
startTime : new Date().getTime()};
var callback = {
//call layoutResult if the request is successful
onSuccess: layoutResults,
//call layoutResult if the request is successful
onSuccess: layoutResults,
//call queryFailed if the api request fails
onFailure: queryFailed,
source: state};
onFailure: queryFailed,
source: state};
sforce.connection.query(
"Select ContractNumber, pricing_contract_number__c From Contract order by ContractNumber limit 30",
callback);
}
"Select ContractNumber, pricing_contract_number__c From Contract order by ContractNumber limit 30",
callback);
}
function queryFailed(error, source) {
source.output.innerHTML = "An error has occurred: " + error;
}
source.output.innerHTML = "An error has occurred: " + error;
}
/**
* This method will be called when the toolkit receives a successful
* response from the server.
* @queryResult - result that server returned
* @source - state passed into the query method call.
*/
function layoutResults(queryResult, source) {
if (queryResult.size > 0) {
var output = "";
* This method will be called when the toolkit receives a successful
* response from the server.
* @queryResult - result that server returned
* @source - state passed into the query method call.
*/
function layoutResults(queryResult, source) {
if (queryResult.size > 0) {
var output = "";
//get the records array
var records = queryResult.getArray('records');
var records = queryResult.getArray('records');
//loop through the records and construct html string
for (var i = 0; i < records.length; i++) {
var account = records[i];
for (var i = 0; i < records.length; i++) {
var account = records[i];
output += account.ContractNumber+ " " + account.pricing_contract_number__c " <br>";
}
}
//render the generated html string
source.output.innerHTML = output;
}
}
</script>
</head>
source.output.innerHTML = output;
}
}
</script>
</head>
<body onload="setupPage()">
<div id="output"> </div>
</body>
</html>
<div id="output"> </div>
</body>
</html>
Hello:
Is this field (pricing_contract_number__c) created in your Contract table in your SFDC instance? If not, that's why it is failing. All fields ending with __c are custom fields created by SFDC customers.
I hope this helps...
Fred
Frederic .. thank you, it worked... now I am trying to run a full query and it is failing... sad enough it sforce only says invalid syntax on run time, although it does say syntax is ok when I do a "check syntax"
Would you please please take a look at this code: thanks....
==============
<html>
<head>
<script src="/soap/ajax/9.0/connection.js" type="text/javascript"></script>
<script>
function setupPage() {
//function contains all code to execute after page is rendered
var state = { //state that you need when the callback is called
output : document.getElementById("output"),
startTime : new Date().getTime()};
var callback = {
//call layoutResult if the request is successful
onSuccess: layoutResults,
//call queryFailed if the api request fails
onFailure: queryFailed,
source: state};
sforce.connection.query(
"select Accrual_or_Additional_Discount__c,Basis__c,Branding__c, Frz_Tarrif_Date__c, Fuel_Surcharge__c, Maximum_Discount__c, Minimum_Discount__c, Misc_Comments__c, Price_Type__c, Pricing_Contract_Number__c, Pricing_Discount__c, Val__c, Val_Type__c, Waive_104__c,
Waive_IRS__c, Waive_Peak__c From Contract order by Branding__c limit 30",
callback);
}
function queryFailed(error, source) {
source.output.innerHTML = "An error has occurred - query: " + error;
}
/**
* This method will be called when the toolkit receives a successful
* response from the server.
* @queryResult - result that server returned
* @source - state passed into the query method call.
*/
function layoutResults(queryResult, source) {
if (queryResult.size > 0) {
var output = "";
//get the records array
var records = queryResult.getArray('records');
//loop through the records and construct html string
for (var i = 0; i < records.length; i++) {
var contract = records[i];
output +=contract.Accrual_or_Additional_Discount__c + " " + contract.Basis__c + " " + contract.Branding__c + " " + contract.Frz_Tarrif_Date__c + " " +contract.Fuel_Surcharge__c + " " + contract .Maximum_Discount__c + " " + contract .Minimum_Discount__c + " " + contract .Misc_Comments__c + " " + contract .Price_Type__c + " " + contract .Pricing_contract _Number__c + " " + contract .Pricing_Discount__c + " " + contract .Val__c + " " + contract .Val_Type__c + " " + contract .Waive_104__c + " " + contract .Waive_IRS__c + " " + contract .Waive_Peak__c + " <br>";
}
//render the generated html string
source.output.innerHTML = output;
}
}
</script>
</head>
<body onload="setupPage()">
<div id="output"> </div>
</body>
</html>
I tried your code on my SFDC instance but i removed all the custom fields, since i have not created them. Instead, i just used the fields Id and Status. It worked. I can definetely conclude that it's a syntax/spelling of one or many custom fields...
One explanation could be that your URL is not properly formed. Meaning that, if you have parameters added to the URL, they are not properly formated.
A correct use would be:
http://www.myurl.com/page_controller?param1=data1¶m2=data2
An incorrect URL would be:
http://www.myurl.com/page_controller¶m1=data1¶m2=data2
The first parameter name must be preceded by a question mark (?) and the following parameters must be followed by an ampersand (&).
Frederic