Saved Search Build : Find And Replace Substrings

Build Difficulty: 💗💗💗💗

The time has come that you need to find certain string in the column and replace it with a hard-coded ones.  Additionally, we are combining this search & replace with a nested comparison logic.

Exercise goal: look at the Posting Period and replace with the first of the month instead of of the abbreviations in the results.  For example, transform from "Feb 2022" to "2-1-2022".

TRANSACTION search

CRITERIA

Posting = T

RESULTS

Document Number

Formula Text = "CASE WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Jan ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','1-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Feb ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','2-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Mar ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','3-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Apr ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','4-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='May ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','5-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Jun ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','6-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Jul ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','7-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Aug ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','8-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Sep ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','9-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Oct ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','10-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Nov ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','11-1-') WHEN REGEXP_SUBSTR({postingperiod},'\A\w\w\w\s')='Dec ' THEN REGEXP_REPLACE({postingperiod},'\A\w\w\w\s','12-1-') ELSE 'In Progress' END"

Word of Wisdom

The part that might need the most time is setting up the regular expression patterns, which you can find decent references online or here is a good place to start.



Comments

Popular posts from this blog

Troubleshoot : Purchase Order did not Auto Generate for Drop Shipping

SuiteScript : Defaulting Tax Code at Line Level