• Jennifer Brown
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
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]);
}
}
}
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]);
}
}
}
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]);
}
}
}