You need to sign in to do that
Don't have an account?
dan.granger.ddw
Update a field and send an email via 1 button
I have a need to send an email from a custom object to an associated contact. I would also like to update the status on the custom object to show that the email is sent and allow a workflow to execute against it.
I located the code to create the email but I would like to update the status field in one click.
I found the following javascript code to update the field (I don't know JS). I tried to update the code to reflect it the way I thought it would work. But I get an error.
{!requireScript("/soap/ajax/26.0/connection.js")}
var Library = new sforce.SObject("Color_Library__c");
Library.id = {!Color_Library__c.Id}
Library.Status__c = 'Tested';
sforce.connection.update([Library]);
The send email code is:
location.replace('/email/author/emailauthor.jsp?retURL=/{!Color_Library__c.Id}&p3_lkid={!Color_Library__c.Id}&rtype=003&p2_lkid={!Color_Library__c.ContactId__c}&template_id=00XK0000000IM3s&p5=');
Is there a way to combine the code into one Javascript code and allow one button?
Any help is appreciated.
Dan
I located the code to create the email but I would like to update the status field in one click.
I found the following javascript code to update the field (I don't know JS). I tried to update the code to reflect it the way I thought it would work. But I get an error.
{!requireScript("/soap/ajax/26.0/connection.js")}
var Library = new sforce.SObject("Color_Library__c");
Library.id = {!Color_Library__c.Id}
Library.Status__c = 'Tested';
sforce.connection.update([Library]);
The send email code is:
location.replace('/email/author/emailauthor.jsp?retURL=/{!Color_Library__c.Id}&p3_lkid={!Color_Library__c.Id}&rtype=003&p2_lkid={!Color_Library__c.ContactId__c}&template_id=00XK0000000IM3s&p5=');
Is there a way to combine the code into one Javascript code and allow one button?
Any help is appreciated.
Dan
Yes, we can override the Standard button and upon cliking that button your Custom Logic can be executed.
See the links below for more information on how to do the same,
Overriding Standard Buttons and Tab Home Pages
https://help.salesforce.com/HTViewHelpDoc?id=links_customize_override.htm&language=en_US
Considerations for Overriding Standard Buttons
https://help.salesforce.com/HTViewHelpDoc?id=links_override_considerations.htm&language=en_US
Sample code in the thread below,
How to override New button into visualforce page for the custom object..
https://developer.salesforce.com/forums/ForumsMain?id=906F00000009FyOIAU
Overriding "Save & New" button on Opportunity edit page
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008nXFIAY
Override standard button in specific condition
http://mindfiresfdcprofessionals.wordpress.com/2013/07/10/override-standard-button-in-specific-condition/
Overriding a Standard Button
http://developer.force.com/cookbook/recipe/overriding-a-standard-button
Regards,
Ashish