You need to sign in to do that
Don't have an account?
Jennifer Brown
Custom javascript button with confirm
I'm very new to javascript and looking for help on a button. It's a custom "Take Ownership" button for cases but I'm looking to do two extra things: 1. Pop up a confirm box if the owner is not null or a queue. I'd also like to insert the owner's full name into the confirm box if possible. (The intent here is to warn a user that someone has already taken ownership of this case if/when that happens.) I'm missing a few things:
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
if(
AND(
{!Case.OwnerFullName} <> "",
{!Case.OwnerFullName} <> "Support Tier 1",
{!Case.OwnerFullName} <> "Support Tier 2",
{!Case.OwnerFullName} <> "Support Tier 3",
{!Case.OwnerFullName} <> "Billing Queue",
{!Case.OwnerFullName} <> "Customer Success",
{!Case.OwnerFullName} <> "Customer Queue")){
if(confirm('This case is already assigned. Are you sure you want to take ownership?')){
var updateRecord = new Array();
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";
result = sforce.connection.query(myquery);
records = result.getArray("records");
if(records[0])
{
var update_Case = records[0];
update_Case.OwnerId = "{!$User.Id}";
update_Case.Status = "Active";
updateRecord.push(update_Case);
result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
}
else {
alert("Error saving case: " + result[0]);
}
}
}
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
if(
AND(
{!Case.OwnerFullName} <> "",
{!Case.OwnerFullName} <> "Support Tier 1",
{!Case.OwnerFullName} <> "Support Tier 2",
{!Case.OwnerFullName} <> "Support Tier 3",
{!Case.OwnerFullName} <> "Billing Queue",
{!Case.OwnerFullName} <> "Customer Success",
{!Case.OwnerFullName} <> "Customer Queue")){
if(confirm('This case is already assigned. Are you sure you want to take ownership?')){
var updateRecord = new Array();
var myquery = "SELECT Id FROM Case WHERE Id = '{!Case.Id}' limit 1";
result = sforce.connection.query(myquery);
records = result.getArray("records");
if(records[0])
{
var update_Case = records[0];
update_Case.OwnerId = "{!$User.Id}";
update_Case.Status = "Active";
updateRecord.push(update_Case);
result = sforce.connection.update(updateRecord);
parent.location.href = parent.location.href;
}
else {
alert("Error saving case: " + result[0]);
}
}
}
But I'm getting this: missing ) after argument list
if ( {!AND(logical1,logical2,...)}
Alain