Last active
April 16, 2024 04:35
-
-
Save jkentjnr/5c44ade9e72407c7ec25eb62ef1245ac to your computer and use it in GitHub Desktop.
Bespoke Salesforce Formulas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates FY as 2022/23 | |
# CampaignDateTime | |
IF( | |
ISBLANK({!StartDate}) == FALSE, | |
{!StartDate}, | |
IF( | |
ISBLANK({!CreatedAt}) == FALSE, | |
{!CreatedAt}, | |
{!$Flow.CurrentDateTime} | |
) | |
) | |
IF( | |
AND(DATEVALUE({!CampaignDateTime}) >= DATE(2022,07,01),DATEVALUE({!CampaignDateTime}) <= DATE(2023,06,30)),'2022/23', | |
( | |
IF((AND(DATEVALUE({!CampaignDateTime}) >= DATE(2023,07,01),DATEVALUE({!CampaignDateTime}) <= DATE(2024,06,30))),'2023/24', | |
( | |
IF((AND(DATEVALUE({!CampaignDateTime}) >= DATE(2024,07,01),DATEVALUE({!CampaignDateTime}) <= DATE(2025,06,30))),'2024/25', | |
( | |
IF((AND(DATEVALUE({!CampaignDateTime}) >= DATE(2025,07,01),DATEVALUE({!CampaignDateTime}) <= DATE(2026,06,30))),'2025/26', | |
( | |
IF((AND(DATEVALUE({!CampaignDateTime}) >= DATE(2026,07,01),DATEVALUE({!CampaignDateTime}) <= DATE(2027,06,30))),'2026/27', | |
'') | |
)) | |
)) | |
)) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATE( | |
VALUE(RIGHT({!InvoiceDate}, 4)), | |
VALUE( | |
MID( | |
{!InvoiceDate}, | |
FIND("/", {!InvoiceDate}) + 1, | |
FIND("/", {!InvoiceDate}, (FIND("/", {!InvoiceDate}) + 1)) - FIND("/", {!InvoiceDate}) - 1 | |
) | |
), | |
VALUE(LEFT({!InvoiceDate}, FIND("/", {!InvoiceDate}) - 1)) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets end of string deliminated by ":" | |
// "campaign:261812" returns as "261812" | |
// "campaign-261812" returns as "campaign-261812" | |
IF( | |
FIND(":", {!Key}) == 0, | |
{!Key}, | |
REVERSE( | |
LEFT( | |
REVERSE({!Key}), | |
FIND(":", REVERSE({!Key})) - 1 | |
) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({!Action} =="donation" && {!IsActor} == TRUE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({!Action} == "metadata") || ({!Action} =="donation" && {!IsActor} == FALSE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example - Takes an ISO DateTime (ie. 1984-04-24T12:00:00.000Z) as a String and produce a Date variable. | |
IF( | |
({!Questions_DateOfBirth} != NULL && FIND("T",{!Questions_DateOfBirth}) > 0), | |
DATEVALUE(LEFT({!Questions_DateOfBirth}, FIND("T",{!Questions_DateOfBirth}) - 1)), | |
NULL | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is over 18. True = yes / False = no / Null = missing birthdate | |
IF ( | |
({!Record.Birthdate} == NULL), | |
NULL, | |
{!Record.Birthdate} <= (ADDMONTHS({!$Flow.CurrentDate}, 0-(12*18))) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replaces the first three words with proper casing ... probably should be a built-in function... | |
# Use: Replace {!Input_Text} with appropriate flow variable. | |
# Credit: https://developer.salesforce.com/forums/?id=906F0000000927nIAA | |
IF ( | |
FIND(" ", {!Input_Text}, 1)=0, | |
UPPER(LEFT({!Input_Text}, 1)) & LOWER(MID({!Input_Text},2,LEN({!Input_Text})-1)), | |
IF( | |
FIND(" ",MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,LEN({!Input_Text})-FIND(" ",{!Input_Text},1)))=0, | |
UPPER(LEFT({!Input_Text}, 1)) & LOWER(MID({!Input_Text}, 2,FIND(" ",{!Input_Text}, 1)-1)) & UPPER(MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,1)) & LOWER(MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 2,LEN({!Input_Text})-1)), | |
UPPER(LEFT({!Input_Text}, 1)) & LOWER(MID({!Input_Text}, 2,FIND(" ",{!Input_Text}, 1)-1)) & UPPER(MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,1)) & LOWER(MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 2,FIND(" ",MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,LEN({!Input_Text} )-FIND(" ",{!Input_Text}, 1)))-1)) & | |
UPPER(MID({!Input_Text}, FIND(" ",MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,LEN({!Input_Text})-FIND(" ",{!Input_Text}, 1))) + FIND(" ",{!Input_Text}, 1) + 1,1)) & LOWER(MID({!Input_Text}, FIND(" ",MID({!Input_Text}, FIND(" ",{!Input_Text}, 1) + 1,LEN({!Input_Text} )-FIND(" ",{!Input_Text}, 1))) + FIND(" ",{!Input_Text}, 1) + 2,LEN({!Input_Text})-1)) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calculates FY as "FY23", etc (only for 2000s years and when FY starts July) | |
IF( | |
ISBLANK({!StartDate}), | |
NULL, | |
IF( | |
MONTH(DATEVALUE({!StartDate})) > 6, | |
"FY" + TEXT( YEAR(DATEVALUE({!StartDate})) - 2000 ), | |
"FY" + TEXT( (YEAR(DATEVALUE({!StartDate})) - 2000) - 1 ) | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 24/60 divides down to minutes. Divide by 1 for 1 minute. Divide by 2 for 2 minutes. | |
{!ModifiedAt}-(1/24/60) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CleanedPostalCode | |
IF(ISBLANK({!MailingAddress_Postcode}), NULL, UPPER(SUBSTITUTE(SUBSTITUTE({!MailingAddress_Postcode}, ' ', ''), '-', ''))) | |
// ------------------------- | |
// ParsedPostalCode | |
IF( | |
LEN({!CleanedPostalCode}) >= 5 && LEN({!CleanedPostalCode}) <= 8, | |
LEFT({!CleanedPostalCode}, LEN({!CleanedPostalCode}) - 3) & " " & RIGHT({!CleanedPostalCode}, 3), | |
NULL | |
) | |
// ------------------------- | |
// IsUKPostcodeValid | |
// - RegEx From https://howtodoinjava.com/java/regex/uk-postcode-validation/ | |
IF(ISBLANK({!ParsedPostalCode}), FALSE, REGEX({!ParsedPostalCode}, '^[A-Z]{1,2}[0-9R][0-9A-Z]? [0-9][ABD-HJLNP-UW-Z]{2}$')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: Takes 0526 or 05/26 and converts to 2026-05-01 as a Date Variable. | |
IF( | |
LEN(TRIM({!DateInput})) == 4 || LEN(TRIM({!DateInput})) == 5, | |
DATEVALUE("20" + RIGHT(TRIM({!DateInput}), 2) + "-" + LEFT(TRIM({!DateInput}), 2) + "-01"), | |
NULL | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment