You need to sign in to do that
Don't have an account?

Quick Mass Close Button trouble
Hi All,
I'm hoping to get some help with this guide on how to make a quick close button that works on a list. I just tried to implement this, and I'm getting an error when I click the button:
"A problem for this on-click javascript button or link was encountered: sforce is not defined"
Any ideas? I confirmed that Closed is indeed a status for the Status picklist and double-checked that I followed the rest of the instructions.
Thanks!
-Jake
I'm hoping to get some help with this guide on how to make a quick close button that works on a list. I just tried to implement this, and I'm getting an error when I click the button:
"A problem for this on-click javascript button or link was encountered: sforce is not defined"
Any ideas? I confirmed that Closed is indeed a status for the Status picklist and double-checked that I followed the rest of the instructions.
Thanks!
-Jake
I can read it OK, and I see this:
{!GETRECORDIDS( Registered_Pen__c.Id )}
That doesn't make any sense. It should either be:
{!GETRECORDIDS( $ObjectType.Registered_Pen__c )}
Or if you're trying to delete Cases and not Registered Pens,
{!GETRECORDIDS( $ObjectType.Case )}
All Answers
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
Hmmm... are you sure? It's returning an error "sforce.connection.delete is not a function"
Here's my code:
Ah! Well, that got me a neat new error:
{faultcode:'soapenv:Client', faultstring:'Unexpected element {urn:partner.soap.sforce.com}type during simple type deserialization', }
Same code as previously posted, only I added the "Ids" to the delete function.
Just do this:
Message Edited by werewolf on 11-20-2008 05:31 PM
You are a scholar and a gentleman!! Thank you so much!!
For the community, here's the complete code for a quick delete case button, courtesy of werewolf:
I am having alittle trouble with this delete function. I have added the code to the search page for this custom object so that when the user finds a record in the search they can check the box next to the record(s) and then click the delete_record button I put on the page. The problem is it never brings in any Id's to delete... So im guessing its something in the syntax for the highlighted line but im not sure what it is.
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var records = {!GETRECORDIDS( Registered_Pen__c.Id )};
if (records[0] == null)
{
alert("Please select at least one case to delete.")
} else {
//Get more info on the cases that were selected and generate a query out of it
var updateRecords = [];
//Iterate through the returned results
for (var recordIndex=0;recordIndex<records.length;recordIndex++)
{updateRecords.push(records[recordIndex]);
}
var result = sforce.connection.deleteIds(updateRecords);
//handle errors here
if (result.error) {
alert('There was an error processing one or more cases');
}
//Reload the list view to show what he now owns
parent.window.location.reload();
}
Thanks
I can read it OK, and I see this:
{!GETRECORDIDS( Registered_Pen__c.Id )}
That doesn't make any sense. It should either be:
{!GETRECORDIDS( $ObjectType.Registered_Pen__c )}
Or if you're trying to delete Cases and not Registered Pens,
{!GETRECORDIDS( $ObjectType.Case )}
Thanks, that works..
{!GETRECORDIDS( $ObjectType.Registered_Pen__c )}
I'm looking for a way to mass close open activities (tasks) from within a ticket.
As a secondary want, I would love to be able to mass close tasks from the home tab. Can someone help me out?
Thanks!
You could conceivably mass close activities using a similar technique -- the problem is that there isn't a single, consolidated Activities view that you can put your custom button on. At least, I don't think there is. The My Tasks view is not a real list view, and it has no checkboxes like normal list views do.
Your only option is probably to build a Visualforce page that shows these activities in a list with checkboxes and gives users the ability to mass close them. That is unfortunately much more complicated than the simple Mass Close code.
I am trying to update some field values using an on-click JS button. I can get the update to work is I hard code the new values, but using the methods shown above I can't update a field on the object to equal a different field on the object.
I assumed that if I used a query call to get the sObjects I wanted to update I could get it to work, but I am having a tough time getting the query to accept a javascript variable for the IN clause. I get a "Malformed_Query" faultcode when I push the button.
{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} var records= {!GETRECORDIDS($ObjectType.SalesOrderLineItem__c)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") ; } else { var test = sforce.connection.query( "SELECT Id, Quantity__c, Quantity_Shipped__c From SalesOrderLineItem__c WHERE Id ='{!GETRECORDIDS($ObjectType.SalesOrderLineItem__c)}'"); alert(test); window.location.reload(); }
Any suggestions?
I noticed an error in the code I posted, I've been making a lot changes trying to get something to work.
The code should read (This still doesn't work):
{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} var records= {!GETRECORDIDS($ObjectType.SalesOrderLineItem__c)}; var newRecords = []; if (records[0] == null) { alert("Please select at least one row") ; } else { var test = sforce.connection.query( "SELECT Id, Quantity__c, Quantity_Shipped__c From SalesOrderLineItem__c WHERE Id IN('{!GETRECORDIDS($ObjectType.SalesOrderLineItem__c)}')"); alert(test); window.location.reload(); }
Very likely the problem is in how you're formatting the query. Try installing Firebug to debug it, store your query in a string, and put
debugger;
after you store the query. Just eyeballing it will probably be enough to show that your IN clause is messed up.
The blogs have moved. It's here now.
It's kind of hard to see it but the text "It's here now" above is a link to the blog post about it.