Strip Text from a Number using flow #inSalesforce
Create a record triggered flow, on create or update
Suppose Contact object and we have two fields License Number String and License Number Numeric
CHOOSE OBJECT: Contact and criteria - LicenseNumberString ISNULL False
Create a variable - to hold the value that is currently in License Number String
varLNS, text type
ASSIGNMENT 1:
varLNS equals record.licenseNUmberString
Create a variable - to hold the length of input String
varLENGTHLNS, number type, decimal zero and default zero
Create a formula variable to get the length of string formulaLENGTHLNS
number type (return type), LEN(varLNS), decimal zero
ASSIGNMENT 2:
assign the length to variable varLENGTHLNS
varLENGTHLNS equals formulaLENGTHLNS
DECISION 1:
YES:
LENGTH > Zero
NO:
LENGTH <= Zero
Create formula to get the first character in the string
formulaFIRSTCHARACTER
LEFT(varLNS,1)
Create new variable to hold the first character varCHARACTER
text type
if yes,
Assign first character to varCHARACTER
varCHRACTER equaks formulaFIRSTCHARACTER
Create formula to test if character is number formulaISNUMBER
ISNUMBER(formulaFIRSTCHARACTER), boolean return type
DECISION 2:
Is first character number
YES:
formulsISNUMBER equals TRUE
NO:
formulsISNUMBER equals False
Create a new variable to hold the new License Number with only numeric digits
varNewLNN
text type
For Yes,
ASSIGNMENT 3:
variableNewLNN Add variableCHARACTER and connect to *
Create formula to trim the string from the right, leaving all but the last character(which is the left most character)
formulaTRIMFIRSTCHARACTER:
TRIM(RIGHT(variableLNS),(varLENGTHLNS)-1))
For No,*
ASSIGNMENT 4:
Remove the first character
variableLNS equals formulaTRIMFIRSTCHARACTER
ASSIGNMENT 5:
Reduce the length counter by 1:
Assignment:
varLENGTHLNS substract 1
Connect to DECISION 1
Loop through testing each character and adding the number digits to LNN
When length = 0 and all characters are looped through, update the contact record
For No on Decision 1,
UPDATE :
specify conditions to identify....
COntact object, ID equals record.contact ID
Set: LengthNumberNumeric equals varnewLNN
Comments
Post a Comment