You need to sign in to do that
Don't have an account?
List Button: Unable to update a field value for multiple records
Hi,
I'm unable to update the Status(PIMS__Status__c) field of a custom Incentive object (PIMS__Incentive__c) with the value "Complete"
i am able to retrieve the record IDs for the Incentive Object sucessfully but am unable to retrieve the value of the Status field for the record id in the loop.
how do i get the value for a field besides the id on a custom object? am i supposed to use a select statement or the get method. i don't seem to be using the get method correctly.
--------------------------
{!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];
var cs = i.get("PIMS__Status__c");
alert("ID = " + i.id + i.PIMS__Status__C + cs );
// 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 records with current status Pending Payment")
}
}
Here is updated script for you
Hope this will help you,
Thanks,
Bala
All Answers
you are trying this exercise in some incorrect way.
As var cs = i.get("PIMS__Status__c") this will always returns NULL,
your code will never enter into your loop , where you are filling the List to update
When we play with some List button , we are having only Record Id not whole record (Which is available in case of a Page Button)
I will post updated script
Thanks,
Bala
Here is updated script for you
Hope this will help you,
Thanks,
Bala
Thanks Bala for your unwavering assistance !!!!! :smileyvery-happy:
you are welcome.....:)
Is it possible to update multiple fields instead of just one?