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
Tania B GarciaTania B Garcia 

Parse email received body autopopulate fields custom in case

Hello

The Email to Case was enabled, the corresponding configurations were made, an email was already linked and the test of sending an email was made and it is received in Salesforce correctly, at the time of receiving the email create a case, a worflow was made to fill certain default fields when the case is created.

At the time of receiving the email, within the body of the email it contains specific information necessary, to be able to fill custom fields that were made corresponding to this information, but through the wf, process builder and flow I have not been able to make the information of the body of the email to these fields.

From what I've read, I think I have what to do through an apex to extract information from the body of the mail, but I have no idea or information on how to make the code in Apex, someone could give me ideas on how to do it apex?

Example of the mail that is received in Salesforce:
Hello,
Registration this ok, plataform: 

Credit Number: 221051400407
Account Name:  XXXYXXX Asignar Formalizador
Opportunity Name:  XXXYXXX Asignar Formalizador
Date Pay: 2021-05-14
Amount: $1
Aplication Pay : Reducción de mensualidad
Archive: Link
Best Answer chosen by Tania B Garcia
Tania B GarciaTania B Garcia
Hi
The description data mapping, there was no need to do it with apex, through workflow and field update with different formulas, use MID, FIND, DATEVALUE, etc ..., depending on the data to extract from the description are the formulas that would be used

Example:
MID(Description, FIND("No. Crédito:", Description)+13,11)
DATEVALUE(MID(Description, FIND("Fecha en que se hizo el pago:", Description)+30, 4) & "-" & MID(Description, FIND("Fecha en que se hizo el pago:", Description)+35, 2) & "-" & MID(Description, FIND("Fecha en que se hizo el pago:", Description)+38, 2))

Thanks and Regards

All Answers

Suraj Tripathi 47Suraj Tripathi 47
Hi,
I have found a similar type of query that you have, please go to the below link:-
https://salesforce.stackexchange.com/questions/233686/parse-email-body-using-strings-to-create-case-and-populate-its-fields

Please mark it as Best Answer if it helps you.

Thanks & Regards
Suraj Tripathi
 
Tania B GarciaTania B Garcia
Hi  Suraj
I already read the link that you left me, if it helps me.
But I also want to see if someone supports me to know how to start the apex class or if there is a reserved word to start with the apex referring to the email?

Thanks and Regards
 
Tania B GarciaTania B Garcia
Hi
Reviewing the subject a little more, in this case as it is well identified where the position of the information that is needed is, it was done through a worflow using formulas to calculate its location
for example
No. Crédito: 221051400407 the formula that was used is MID(Description, FIND("No. Crédito:", Description)+13,11)

Although the one that is making me more difficult is the case of the Amount because in that it can vary the length up to 16 digits with its 2 digits after the point
If someone could help me how to do it with formula, this is how you can several example
Amount: 500,000.00
Amount: 78,546,000.00
Amount: $ 7,963,877,100,300,000.00

Thanks and Regards
Tania García
Tania B GarciaTania B Garcia
Hi
The description data mapping, there was no need to do it with apex, through workflow and field update with different formulas, use MID, FIND, DATEVALUE, etc ..., depending on the data to extract from the description are the formulas that would be used

Example:
MID(Description, FIND("No. Crédito:", Description)+13,11)
DATEVALUE(MID(Description, FIND("Fecha en que se hizo el pago:", Description)+30, 4) & "-" & MID(Description, FIND("Fecha en que se hizo el pago:", Description)+35, 2) & "-" & MID(Description, FIND("Fecha en que se hizo el pago:", Description)+38, 2))

Thanks and Regards
This was selected as the best answer