• Sean Tisdale
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am not a JS developer so I'm struggling to get my head around this.  

I am bulding a JS OnClick button that updates the Owner field in a custom object to a queue.  

Here's the code:
{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")} 

var SupportRequestObj = new sforce.SObject("SupportRequest__c"); 
SupportRequestObj.Id = '{!SupportRequest__c.Name}'; 
SupportRequestObj.OwnerId = '00G50000001dv2s'; 
var result = sforce.connection.update([SupportRequestObj]); 
window.location.href=window.location.href;

The custom object's API name is SupportRequest__c and the Object Name is SupportRequest.

The Syntax comes back clean but when the button is clicked there's nothing. No error. No update to the owner field.  

What am I doing wrong?
 have a custom object called "SupportRequest" with a record type used by our sales and contracts team. I need to have a manual trigger (in this case a detail page button) that allows the creator of the record to update the record owner to a queue with a single click.

I am using this JS for the button:
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} try{ var CCA_QueueId; var CCA_QueueName = "CCA_Queue"; var queues = sforce.connection.query( "SELECT Id " + "FROM Group " + "WHERE Name = '" + CCA_QueueName + "'" ); if( queues.getArray( "records" ).length === 0 ) { alert( "Couldn't find a Queue with Name: " + CCA_QueueName + "!" ); } else { CCA_QueueId = queues.getArray( "records" )[0].Id; } if( CCA_QueueId !== undefined ) { var reqToUpdate = new sforce.SObject( "SupportRequest__c" ); reqToUpdate.Id = "{!SupportRequest__c.Id}"; reqToUpdate.OwnerId = CCA_QueueId; var result = sforce.connection.update( [reqToUpdate] ); if( result[0].getBoolean( "success" ) === true ) { location.reload(); } else { alert( "An Error has Occurred. Error: " + result[0].errors.message ); } } } catch( e ) { alert( "An Error has Occurred. Error: " + e.message ); }

This is code modified from other used and not my original work. I'm sure I'm missing somethign elementary but this falls outside of my skillset.  
Another note - the Queue API name is CCA_Queue but the Label is Contracts Queue if that makes any difference.

Thanks 
 have a custom object called "SupportRequest" with a record type used by our sales and contracts team. I need to have a manual trigger (in this case a detail page button) that allows the creator of the record to update the record owner to a queue with a single click.

I am using this JS for the button:
{!REQUIRESCRIPT("/soap/ajax/35.0/connection.js")} try{ var CCA_QueueId; var CCA_QueueName = "CCA_Queue"; var queues = sforce.connection.query( "SELECT Id " + "FROM Group " + "WHERE Name = '" + CCA_QueueName + "'" ); if( queues.getArray( "records" ).length === 0 ) { alert( "Couldn't find a Queue with Name: " + CCA_QueueName + "!" ); } else { CCA_QueueId = queues.getArray( "records" )[0].Id; } if( CCA_QueueId !== undefined ) { var reqToUpdate = new sforce.SObject( "SupportRequest__c" ); reqToUpdate.Id = "{!SupportRequest__c.Id}"; reqToUpdate.OwnerId = CCA_QueueId; var result = sforce.connection.update( [reqToUpdate] ); if( result[0].getBoolean( "success" ) === true ) { location.reload(); } else { alert( "An Error has Occurred. Error: " + result[0].errors.message ); } } } catch( e ) { alert( "An Error has Occurred. Error: " + e.message ); }

This is code modified from other used and not my original work. I'm sure I'm missing somethign elementary but this falls outside of my skillset.  
Another note - the Queue API name is CCA_Queue but the Label is Contracts Queue if that makes any difference.

Thanks