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
gregj777gregj777 

Adding standard text at the end of a value

Wondering if someone has an idea on how to add text at the end of  a value after it has been entered. I have a field where the user enters a value but I want the result to add a standard text so they don't have to retype all the time.

 

Ex. User enters:  12.5

Result is: 12.5 cm H2O ( so the standard text is "cm H2O" all the time)

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
goabhigogoabhigo

Workflow is the solution for you.

 

  • Rule criteria: 'yourfield' not eqauls null(any of the evaluation criteria will work for you, I guess. But use Every time a record is created or edited)
  • Field update: Formula value would be: yourfield__c + ' cm H2O'

 

 

Activate the workflow and enjoy :)

All Answers

apaiapai

Is the field type - text ? Also, is the value to be appended always the same ?

 

You can setup a workflow rule to update the field value, whenever a record is created or updated.

 

Add a workflow action  - Field update. In the field value, select use a formula and use RPAD function to append the desired value.

 

 

goabhigogoabhigo

Workflow is the solution for you.

 

  • Rule criteria: 'yourfield' not eqauls null(any of the evaluation criteria will work for you, I guess. But use Every time a record is created or edited)
  • Field update: Formula value would be: yourfield__c + ' cm H2O'

 

 

Activate the workflow and enjoy :)

This was selected as the best answer
goabhigogoabhigo

 

RPAD

 

Description:Inserts characters that you specify to the right-side of a text string.
Use:
RPAD(text, padded_length[, 'pad_string']) and replace the variables:
  • text is the field or expression after which you want to insert characters.
  • pad_length is the number of total characters in the text string that will be returned.
  • pad_string is the character or characters that should be inserted. pad_string is optional and defaults to a blank space.
If the value in text is longer than pad_string, text is truncated to the size of padded_length.
Example:Account Name: Padding Default

RPAD(Name, 20) truncates the Name field after 20 characters. For example, if the name is salesforce.com, the value returned is “salesforce.com.”

My_Company: No Change

RPAD('my_company.com', 14, 'z') returns “my_company.com” without change because it has 14 characters.

Account Name: Padding with a Character

RPAD(Name, 15, 'z') returns “salesforce.comz” .

Account Name: Truncating

RPAD(Name, 2) truncates the name after the second character. For example, if the name is salesforce.com, the value returned is “sa.”

Tips:Salesforce omits ending blank spaces.

 

So RPAD is not helpful here I guess.

gregj777gregj777

Worked...thank you.