You need to sign in to do that
Don't have an account?
Sean Tisdale
JavaScript Button to Update Record Owner
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:
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
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
This can be handled using flow. That way your solution is ready for Lightning Experience.
You can call a flow from a button. Just create an URL button and call the url for the flow you create. Example of the url would be "/flow/FLOWNAME"