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
StaciStaci 

button to update fields and send email

I want a button on Soltuions to be able to email me when a Soltuion needs to be udpated.  I have the following link
/_ui/core/email/author/EmailAuthor?p3_lkid={!Solution.Id}&retURL=%2F{!Solution.Id}&{!(ISPICKVAL(Solution.Status, "Needs Update"))}&p5="gilmore_staci@cat.com"&p24="mansfield_matthew@cat.com"&template_id=00X19000000QFda
The email send fine, but I can't get the fields to update.  I have it trying to change the Status field to Needs Update.  How can I get it to do this?
Status is a picklist.  I also want a checkbox to uncheck. TIA!
 
Best Answer chosen by Staci
KaranrajKaranraj
You can't update the record thourgh url parameter in salesforce. Instead change your button type as javascript and try with the below code
 
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var solObj = new sforce.SObject("Solution"); 
solObj.Id = '{!Solution.Id}'; 
solObj.Status = 'Needs Update';
sforce.connection.update([solObj]); 
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Solution.Id}&retURL=%2F{!Solution.Id}&p5="gilmore_staci@cat.com"&p24="mansfield_matthew@cat.com"&template_id=00X19000000QFda')

 

All Answers

KaranrajKaranraj
You can't update the record thourgh url parameter in salesforce. Instead change your button type as javascript and try with the below code
 
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}

var solObj = new sforce.SObject("Solution"); 
solObj.Id = '{!Solution.Id}'; 
solObj.Status = 'Needs Update';
sforce.connection.update([solObj]); 
location.replace('/_ui/core/email/author/EmailAuthor?p3_lkid={!Solution.Id}&retURL=%2F{!Solution.Id}&p5="gilmore_staci@cat.com"&p24="mansfield_matthew@cat.com"&template_id=00X19000000QFda')

 
This was selected as the best answer
StaciStaci
Thanks @karanraj, that worked!
StaciStaci
hi @karanraj I have one question.  Do you know what the permission would be to access the email?  As myself, I can send the email fine, i have admin rights.  As one of our Tier 2 guys its saying insufficient privs.  They already have visibility to all the fields that are changing.
Adriana VoyceAdriana Voyce
Hi @karanraj I hope you see this message... I am trying to do something similar, but I am receiving an error if there is any chance you could help me, here is my post: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BQS0IAO     Thanks