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
Steve FerreeSteve Ferree 

email from Apex trigger - need to add custom case field

Ok I am new to Apex, this should be easy  but I am not finding a good resource manual. I have a Apex trigger to send an form email whenever a case changes owner.
What I'd like to do is include a link to the orginal case.

Here is what I think is the relevant lines as they exist

mail.setSubject('You are now the Owner of Case#:'+Trigger.new[i].CaseNumber);
                  mail.setPlainTextBody('Ownership of Case#:'+Trigger.new[i].CaseNumber+' has been set to you. Have a Nice Day.');

so I need to change this from plain text and include a field from the case containing the threadID so it'll link back to the case.
can that field be included?
Best Answer chosen by Steve Ferree
souvik9086souvik9086
You mean there will be a field in Case where it will store the link back to case like for e.g('/'+case.id)?

You can write like this
Get the host in the trigger like for e.g for developer edition
mail.setPlainTextBody('https://ap1.salesforce.com/'+Trigger.new[i].Id);

All Answers

Vishant ShahVishant Shah
Why dont you use workflow and email alerts?
souvik9086souvik9086
You mean there will be a field in Case where it will store the link back to case like for e.g('/'+case.id)?

You can write like this
Get the host in the trigger like for e.g for developer edition
mail.setPlainTextBody('https://ap1.salesforce.com/'+Trigger.new[i].Id);
This was selected as the best answer