1

I have built a series of lightning components that we will use as pages in salesforce 1 mobile application. One of the pages offers the user the ability to share our pages content with their group via "email this", "chat this" or "create todo" buttons. Is this possible?

It looks like I would need to follow the process outlined here How to call a Salesforce REST URL from Lightning Component?

  1. Create an Apex client for the REST API
  2. Create an Apex controller for your Lightning app
  3. Create your Lightning app, and bind it to the controller
  4. Specify an init handler for your app
  5. Configure the handler to enqueue the Apex controller's action to execute the REST API operation

but I am a salesforce newb, can anyone confirm that this is the best path forward for me to provide this funtionality?

4

Email, Chatter and Task creation are all things that you can do directly in Apex without having to call the REST API. Being the native programming language on Force.com, Apex is tightly coupled so as to prevent lots of manual API calls.

For the task creation (the ToDo as you call it) the Apex controller need simply do something like:

Task myTask = new Task();
myTask.subject = 'Check Out This Content';
...assign other fields...
insert myTask;

Email assignment and chatter posts are similarly easy but have some special rules. For email there are a set of classes you use specifically to access the Email service. For Chatter look for the classes in the ConnectAPI namespace as these are internal wrappers for the Chatter REST API.

So when do you need to actually go the distance and make that loopback REST APIS request? Well, typically only when there is something in the API that is not supported by Apex directly. These are often more advanced activities related to introspection of metadata, invoking developer features, etc. For your average business data operations Apex normally has plenty to offer.

I would suggest sitting down and skimming the Apex Developer Guide as a start. There is an Apex workbook for not hands-on practice. Or for a bit of fun have a look at the trailhead learning experience at developer.salesforce.com/trailhead.

Please excuse any bad typing as I am answering from my iPhone. I will return and edit this answer when I can get to my laptop and add links to docs and correct any vagueness

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.