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
mlundwallmlundwall 

Queue id from name in javascript

Hi,

 

I want to make a button that escalates a Case depending on what queue you have choosen from a picklist. I have only found a way to store the name of the queue in the picklist which so I need to translate the queue name to id in javascript.

 

Any clues on how to do that?¨

 

So far my code looks like...

 

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

var newRecords = [];
 
var c = new sforce.SObject("Case");
c.id ="{!Case.Id}";

var escalation = "{!Case.Escalation__c}";
var q = new sforce.SObject("Queue");
q.Name = escalation;

c.OwnerId = "q.Id";
newRecords.push(c);
 
result = sforce.connection.update(newRecords);

 
window.location.reload();

 

thanks

Martin

Best Answer chosen by Admin (Salesforce Developers) 
mlundwallmlundwall

Just wanted to share my solution:

 

This is the javascript code for a button that escalates the Case depending on what Queue name that is selected from a picklist.

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

var newRecords = [];
 
var c = new sforce.SObject("Case");
c.id ="{!Case.Id}";

var result = sforce.connection.query("Select Id, SobjectType, QueueId, Queue.Name From QueueSobject where Queue.Name = '{!Case.Escalation__c}'");

if (result['size'] == 1){
   
var queue_records = result['records'];

c.OwnerId = queue_records['QueueId'];
newRecords.push(c);
}

result = sforce.connection.update(newRecords);

 
window.location.reload();