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
Jaye LoweJaye Lowe 

Flow to remove everything after a character from long text

Hey all, here's the deal. I have a long text area, which is basically a really long url that I need to cut everything after the question mark and then copy into a URL field. Preferrably, in a declarative fashion. Any ideas? 
Best Answer chosen by Jaye Lowe
SubratSubrat (Salesforce Developers) 
Hello ,

To achieve this requirement in a declarative manner (without writing code), you can use a combination of Salesforce's Process Builder and a formula field. Here's the step-by-step process to cut the text after the question mark and copy it into a URL field:

Create a Custom URL Field:
First, create a custom URL field on the object where you have the long text area field. Let's call it "URL_Field__c."
Create a Formula Field to Extract URL:
Create a new formula field of type "Text" on the same object. In this formula field, you can use the LEFT and FIND functions to extract the part of the long text area field before the question mark. Let's call this formula field "URL_Extract__c."
Formula for "URL_Extract__c":
LEFT(Long_Text_Area_Field_c, FIND("?", Long_Text_Area_Field_c) - 1)
Use Process Builder to Copy the Extracted URL:
Now, use Salesforce's Process Builder to copy the extracted URL from "URL_Extract_c" to the custom URL field "URL_Field_c."
Steps to Create Process Builder:

Object: Select the object where the long text area field and the custom URL field exist.
Start the process: When a record is created or edited.
Criteria: Use the formula condition to check if the "Long_Text_Area_Field__c" is not blank.
Immediate Action: Update records. Set the "URL_Field_c" to the value of "URL_Extract_c."
Save and activate the Process Builder.

With this setup, whenever the long text area field is created or updated with a value containing a question mark, the Process Builder will extract the URL and copy it to the custom URL field "URL_Field__c."

Hope this helps !
Thank you.

All Answers

SubratSubrat (Salesforce Developers) 
Hello ,

To achieve this requirement in a declarative manner (without writing code), you can use a combination of Salesforce's Process Builder and a formula field. Here's the step-by-step process to cut the text after the question mark and copy it into a URL field:

Create a Custom URL Field:
First, create a custom URL field on the object where you have the long text area field. Let's call it "URL_Field__c."
Create a Formula Field to Extract URL:
Create a new formula field of type "Text" on the same object. In this formula field, you can use the LEFT and FIND functions to extract the part of the long text area field before the question mark. Let's call this formula field "URL_Extract__c."
Formula for "URL_Extract__c":
LEFT(Long_Text_Area_Field_c, FIND("?", Long_Text_Area_Field_c) - 1)
Use Process Builder to Copy the Extracted URL:
Now, use Salesforce's Process Builder to copy the extracted URL from "URL_Extract_c" to the custom URL field "URL_Field_c."
Steps to Create Process Builder:

Object: Select the object where the long text area field and the custom URL field exist.
Start the process: When a record is created or edited.
Criteria: Use the formula condition to check if the "Long_Text_Area_Field__c" is not blank.
Immediate Action: Update records. Set the "URL_Field_c" to the value of "URL_Extract_c."
Save and activate the Process Builder.

With this setup, whenever the long text area field is created or updated with a value containing a question mark, the Process Builder will extract the URL and copy it to the custom URL field "URL_Field__c."

Hope this helps !
Thank you.
This was selected as the best answer
Jaye LoweJaye Lowe
This has been extremely helpful. The formula field wouldn't let me use the long text field in the formula so I just copied your formula into a flow and it worked great. Thanks! One more question, if there is not a questions mark I still need to copy the exact url into the url field. Can the formula handle this? Thanks. 
Jaye LoweJaye Lowe
Nevermind. I created a Decision wher it looked for the question marked in the Long text field. If it found one it updated the record with the formula result if it didn't it just copied the results as is into the URL field. Again, thanks!