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
huskerwendyhuskerwendy 

Using Flow & Process Builder to Parse Case Subject Line

I've been told that I can parse the subject line of a case using flow and process builder but I really have no idea where to start. Can someone give me an outline of the steps I would take? I've done some investigating in flow but the only thing I can see that may work would be to use a loop variable but I don't know if I'm even heading in the right direction. 

Here's what I'm hoping to accomplish: 
We have cases that all come in from the same email address. The email address is not associated with any of the contacts on the accounts however they have the correct account number in the subject line of the case. I need to assign the case to the correct account based on the account number in the case subject line. All of the account numbers are six characters long. 

Here's an example of what the subject line would look like: "123456 Backups complete on "
Best Answer chosen by Andy Boettcher
huskerwendyhuskerwendy
I'm glad you replied because I've been meaning to come back here and post the solution. I actually got it to work. I created a headless flow and am calling that from process builder. The flow uses a fast lookup to get the case and assign it to an sobject. I'm passing in the case id in from Process Builder and assigning it to a variable. In the flow, I created a formula that parses the case subject by getting the first six characters of the subject (LEFT({!sobjCase.Subject}, 6)). Then I used assignment logic to assign that formula to a variable. Then I added another record lookup to lookup the Account ID from the variable varAccountNum. Then, I added a record update to update the account on the case.

User-added image
 

All Answers

Andy BoettcherAndy Boettcher
Gotcha.

To speak it back - you are looking to analyze new Cases that came in via Email to Case that put the Account Number in the Case.Subject line - and then reassign that Case to the proper account based on that value?

I'm racking my brain on a native Flow component that would allow you to parse that string like that - but you may need to throw in a little Invocable Apex to do the assignment for you.  You can implement that Invocable Apex either inside of a Flow or just in Process Builder itself I believe.

The Apex would accept a list of new Cases and then spin through programmatically to assign them.  Have you tried any programmatic approach yet?
huskerwendyhuskerwendy
I'm glad you replied because I've been meaning to come back here and post the solution. I actually got it to work. I created a headless flow and am calling that from process builder. The flow uses a fast lookup to get the case and assign it to an sobject. I'm passing in the case id in from Process Builder and assigning it to a variable. In the flow, I created a formula that parses the case subject by getting the first six characters of the subject (LEFT({!sobjCase.Subject}, 6)). Then I used assignment logic to assign that formula to a variable. Then I added another record lookup to lookup the Account ID from the variable varAccountNum. Then, I added a record update to update the account on the case.

User-added image
 
This was selected as the best answer
huskerwendyhuskerwendy
Here's the Assignment:
User-added image
Andy BoettcherAndy Boettcher
Awesome and thank you for posting the answer!  I'll mark you as best answer to help others down this same path.  =)
JaySuper_NewbieJaySuper_Newbie
Huskerwendy, 
 I would like to replicate what you have done, my issue is that I don't know enough about how Flows and how to build them.  From a logic stand point I totally get it.  Is there a way you could share with me screen shots of each item in your flow and your process builder.  I know its a lot to ask but I am struggleing with this on multiple fronts.  
huskerwendyhuskerwendy
JaySuper_newbie - I just ran across this post and noticed your question. Did you ever get it figured out? I will take screen shots if you still need help. 
JaySuper_NewbieJaySuper_Newbie
huskerwendy,
Screen shots that would help would be great.  I still want to do the same thing where I am parsing a value out of subject line to get the Account number. 

Thanks for your help!
huskerwendyhuskerwendy
Here you go. I hope it helps. Let me know if you have any questions.User-added image

User-added image

User-added image

User-added image

User-added image

 
JaySuper_NewbieJaySuper_Newbie
Great Thanks!! 
 
JaySuper_NewbieJaySuper_Newbie
I'll let you know how it goes in a few days
 
adasadas
huskerwendy, your solution was super helpful -- thank you. One issue I am having is that the variables are not clearing after each case, and so after the first one, all the subsequent cases have the same account number as the first record that went through the flow. Are you seeing this at all?
huskerwendyhuskerwendy
Adas, I don't see that issue because my flow is called from a Process Builder when a record is created or edited. You may be able to add an assignment to your flow that clears those values before it moves on to the next record.
adasadas
I went back to your screenshots and realized my CaseID variable wasn't set to input. Your solution is working well now. Thanks huskerwendy!
James BuckelewJames Buckelew
I'm trying to figure this out, and I think I am confused. I am having issues creating a process builder that will pull the case ID into the flow. I am very new to this and am trying to figure this out. Thanks for any help!
huskerwendyhuskerwendy
James you have to have a variable declared in your flow. Call it something like "vCaseID". The data type should be text and then you check the box called 'Available for Input'. 
User-added image

Also your flow type should be "Autolaunched Flow" 
User-added image

Then in your process builder, you would select "Flows" as the Action Type and then find the name of your flow in the picklist. Any variables you declared as "Available for Input" will show up in  "Set Flow Variables".
User-added image
Hope this helps! Let me know if you have other questions.
 
Eboni Blake 19Eboni Blake 19
Can you add the formula to parse out the subject? We have been having issues with our formula returning a null value. We want to pull in the 7 characters to the left of "Legal Agreement: ".
RIGHT({!SubjectLegalAgreement}, FIND("Legal Agreement: ",{!SubjectLegalAgreement},7))
 
 
 
 
huskerwendyhuskerwendy
I used the SUBSTITUTE function which subsitutes "Email - " with nothing to get just the email address from the case subject.
SUBSTITUTE( {!sobjCase.Subject} , 'Contact Form Email - ','')