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
QMEQME 

help!! custom object query problems

i am having difficultly trying to retrieve information from a custom object.  this piece of javascript code is to be executed by clicking a button on the list view.

 

i am trying to retrieve the custom "Status" field on the custom object "Incentive" (there is a namespace prefix of PIMS)

 

for some reason i cannot seem to get the syntax of the query quite correct.  the code keeps bombing out before i get to the alert that states "Selection query successful"

 

any insight would be great!!

 

 

 

 

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

var userList = {!GETRECORDIDS($ObjectType.PIMS__Incentive__c )}
var updatedList = [];

if (userList[0] == null) {
alert("Please select at least one record.") }
else {
var answer = confirm("Are you sure?");
if (answer==true) {

for (var n=0; n<userList.length; n++) {
var i = new sforce.SObject("PIMS__Incentive__c");
i.id = userList[n];


alert("The ID has been correctly retrieved - ID = " + i.id );


var result = sforce.connection.query("Select PIMS__Status__c from PIMS__Incentive__c where ID = 'i.id' ");


alert("Selection query successful" );

// only update records where current status is Pending Payment
if (i.PIMS__Status__c == "Pending Payment") {
alert("You have selected " + userList.length + " records");
i.PIMS__Status__c = "Complete";
updatedList.push(i);
}
}
result = sforce.connection.update(updatedList);
window.location.reload();
alert("Status set to Complete for all selected Incentive Programs with current status Pending Payment")
}
}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

here is your updated Query

 

alert("The ID has been correctly retrieved - ID = " + i.id );


var result = sforce.connection.query("Select PIMS__Status__c from PIMS__Incentive__c where ID = '"+ i.id + "'");

hope it will help you

 

Thanks,

Bala