2

I was trying to find a way to notify an account owner when new notes are added to their account, but I wasn't able to find anything. I also tried using the process builder but I didn't see anything about notes in there. How would I implement this functionality?

  • I added the flow logic for you. – cricketlang Oct 7 '15 at 19:09
1

Unfortunately, the Note object is not supported in Process Builder at this time, so you would be forced into a trigger if you want to fire something off when one is created.

Personally, I'm a Flow guy, and if it were my approach, I would create a simple trigger on the Note object to just pass the new Note Id to a flow, and handle whatever actions i want to handle from within the flow. You can grab the ParentId on the Note object and the note details with a Record Lookup and then Lookup the Account Object with the ParentId returned to grab the account owner or whatever from there.

You could also do all the logic in a trigger, but i rather just have triggers on these non bulk, non Process Builder objects that just pass the Id to a flow to do whatever things i want to do. If i want to do something that the Flow designer doesn't do by default, then i typically write a Flow Plugin or Invokable Method that I can just import into the Flow.

Below is a basic trigger for the Notes object that will pass the newly created Note Id to the NoteAlert flow that you can create to do whatever you want after a note has been created. It is created to pass the Id to an Input Parameter in the Flow named NoteId, so if you use it be sure to add that as an input variable. Hopefully this helps you get on the right path. If you have any questions, feel free to ask!

trigger FireNoteFlowTrigger on Note (after insert) {
//after the note is inserted, grab the Id of the new note so we can pass it to the Flow
String noteId = trigger.new[0].Id;
//create a new map of params to pass to the flow
Map<String, Object> params = new Map<String, Object>();
//put the params in the map
params.put('NoteId', noteId);
//create a new instance of the flow and pass the params (noteId)
Flow.Interview.NoteAlert noteAlertFlow = new Flow.Interview.NoteAlert(params);
//start the flow
noteAlertFlow.start();
}

And here is a screenshot of the Flow just for a basic start

enter image description here

So for the Flow setup, the first thing i want to do is setup a new Flow and call it NoteAlert and set it as an Autolaunched Flow (do this so you can pretty much copy and paste that trigger code above and have it work)

enter image description here

Before you do anything else, setup an input variable called NoteId that we will pass to the Flow from the trigger.

enter image description here

After you do that, create your first Record Lookup that will go and get all the details for the Note that was just created. You will use the NoteId to lookup the note. Set this is as your starting element.

enter image description here

The next step is to try and lookup an Account with the ParentId of the Note. Notes can be attached to a few different objects, so if you only want to set an alert on an Account note, you want to lookup Account to make sure its an Account Note. You could additionally run lookups for other objects, but here i just lookup Account. If i find the account, i want to grab the ownerId so i can get the Account Owner's email address later.

enter image description here

Next I make a decision on whether or not the account lookup found an account or not. I do this based off the return of the account lookup being null or not.

enter image description here

If the account is found, I want to lookup the account owners email address so i know where I'm sending the email to. I do this by looking up the user object with the Account Owner Id

enter image description here

Now that i have all the note details, and the owners Id, i can really do whatever i want here. In your question, you want to send an email, so i just threw the values into a basic Send Email plugin that would send an email out. You may want to do something like a formula that allows you to maybe write some email content which tells the user what the email is, but in my basic example i just make the subject of the email the note title and the email body the body of the note. You'll have to decide how you want to do that part, but this should set you in the right direction.

enter image description here

After that, you should be set to go. The trigger will fire off when the note gets created, it will pass that new noteId to the Flow, and the flow will determine if its an account note and will send the account owner an email if it is. Dont forget to activate the Flow after you create it or it wont work.

Let me know if you have any other questions.

| improve this answer | |
  • Hi, thanks! I've never used flows before however, so I'm not entirely sure as to what details to put in each part. Could you help? – AKor Oct 6 '15 at 16:22
  • Yeah give me a sec and I'll break it all out for you. – cricketlang Oct 6 '15 at 16:51

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.