• About

Salesforce Everywhere

~ All about Salesforce

Salesforce Everywhere

Monthly Archives: February 2016

Tip#19 – Using workbench to execute APEX

10 Wednesday Feb 2016

Posted by Mani in Apex, Uncategorized

≈ 2 Comments

Tags

Salesforce Tips

Today, I was working on a requirement which queries public group and sends an email to the users(group members) with an attachment from the custom object record and it was implemented using APEX code. I wanted to test using Execute Anonymous option in Developer Console before I call the code using process builder. When I tried executing it in Developer Console, it was throwing Sending Request – Execution Failed error. I could not figure out the reason for it, but I realised that using workbench to execute Anonymous APEX code is better than Dev Console since your code, results are displayed in the same page and you can set the log level too.

Steps to execute APEX in Workbench:

a. Login to https://workbench.developerforce.com
b. Select Sandbox or Production(obviously, we will test the code in Sandbox first)
c. Then system will ask you to login to Salesforce
d. Once logged in, select “Apex Execute” in Jump to option
e. Paste your code in the text box and click on Execute button.
f. System will show the results on the same page. You can select the appropriate Log category and Log level too.

In the future post, I will write about creating a flow to query the public group based on the name and send an email to the group members(role based members).

Advertisements

Tip#18 Get Salesforce instance in Apex

09 Tuesday Feb 2016

Posted by Mani in Apex, Uncategorized

≈ Leave a comment

Tags

Salesforce Tips

Recently, I worked on a requirement where in I had to send an email by using APEX and I had to prepare the HTML body within APEX itself. As part of it, there has to be a clickable link in the email which should take the user to the Salesforce record after clicking on it and we should not hardcode the URL in the code.

So, here is the code below to get the logged in user’s URL and concatenate it with the Salesforce record ID:

String u=System.Url.getSalesforceBaseURL().toExternalForm();//this returns the base URL of the Salesforce instance as String.
String ufinal=u+’/’+POId;//POId is the variable that holds Id of the custom object record.

or you can write the above code in one line:

String ufinal = URL.getSalesforceBaseUrl().toExternalForm() + ‘/’ + POId;

Blog Stats

  • 54,395 hits

Archives

  • May 2018 (1)
  • April 2018 (4)
  • December 2017 (1)
  • October 2017 (1)
  • July 2017 (3)
  • June 2017 (1)
  • April 2017 (1)
  • March 2017 (1)
  • June 2016 (1)
  • May 2016 (6)
  • April 2016 (1)
  • March 2016 (2)
  • February 2016 (2)
  • January 2016 (1)
  • December 2015 (3)
  • November 2015 (2)
  • October 2015 (4)
  • September 2015 (10)
  • August 2015 (6)
  • April 2015 (2)
  • March 2015 (3)
  • February 2015 (1)

Recent Posts: Salesforce Everywhere

Duration of the events in the Salesforce calendar can’t go beyond 14 days

Tip # 25: Error in creating Lookup relationship

Salesforce Certified Platform Developer I – Spring ’18 Release Exam

Salesforce Certified Platform App Builder – Spring ’18 Release Exam

Salesforce Certified Administrator – Spring ’18 Release Exam

Developer links

  • Salesforce Developer website
  • ForcePrepare
  • Salesforce Success Community

Connect with me

  • View @manibalan_s’s profile on Twitter
  • LinkedIn
Advertisements

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 12 other followers

Create a free website or blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy