sfmc-devtools icon indicating copy to clipboard operation
sfmc-devtools copied to clipboard

[FEATURE] add method replaceReference to find&replace contentBlockByX with one of the other options

Open JoernBerkefeld opened this issue 2 months ago • 0 comments

test platform: https://regex101.com/#javascript

relevant types that could contain amscript:

  • script
  • journey (email related)
  • triggeredSend
  • asset (email, content blocks, ...)
  • senderProfile

regex:

  • ContentBlockByID: /ContentBlockById\(\s*"([0-9]+)"\s*\)/gmi & /ContentBlockById\(\s*'([0-9]+)'\s*\)/gmi

  • ContentBlockByKey: /ContentBlockByKey\(\s*"([a-z0-9-\/._]+)"\s*\)/gmi & /ContentBlockByKey\(\s*'([a-z0-9-\/._]+)'\s*\)/gmi

  • ContentBlockByName: /ContentBlockByName\(\s*"([ a-z0-9-\\._]+)"\s*\)/gmi & /ContentBlockByName\(\s*'([ a-z0-9-\\._]+)'\s*\)/gmi

test strings

  • ContentBlockByKey
// double quote

%%=contentblockbykey("abc123-/._abc123")=%%
%%=ContentBlockByKey("abc123-/._abc123")=%%
%%= ContentBlockByKey("abc123-/._abc123") =%%
%%= ContentBlockByKey( "abc123-/._abc123" ) =%%
%%= ContentBlockByKey( "abc123-/._abc123"  ) =%%
%%= ContentBlockByKey(  "abc123-/._abc123"  ) =%%

%%=contentblockbykey("0b76dccf-594c-b6dc-1acf-10c4493dcb84")=%%
%%=ContentBlockByKey("0b76dccf-594c-b6dc-1acf-10c4493dcb84")=%%
%%= ContentBlockByKey("0b76dccf-594c-b6dc-1acf-10c4493dcb84") =%%
%%= ContentBlockByKey( "0b76dccf-594c-b6dc-1acf-10c4493dcb84" ) =%%
%%= ContentBlockByKey( "0b76dccf-594c-b6dc-1acf-10c4493dcb84"  ) =%%
%%= ContentBlockByKey(  "0b76dccf-594c-b6dc-1acf-10c4493dcb84"  ) =%%

// single quote

%%=contentblockbykey('abc123-/._abc123')=%%
%%=ContentBlockByKey('abc123-/._abc123')=%%
%%= ContentBlockByKey('abc123-/._abc123') =%%
%%= ContentBlockByKey( 'abc123-/._abc123' ) =%%
%%= ContentBlockByKey( 'abc123-/._abc123'  ) =%%
%%= ContentBlockByKey(  'abc123-/._abc123'  ) =%%

%%=contentblockbykey('0b76dccf-594c-b6dc-1acf-10c4493dcb84')=%%
%%=ContentBlockByKey('0b76dccf-594c-b6dc-1acf-10c4493dcb84')=%%
%%= ContentBlockByKey('0b76dccf-594c-b6dc-1acf-10c4493dcb84') =%%
%%= ContentBlockByKey( '0b76dccf-594c-b6dc-1acf-10c4493dcb84' ) =%%
%%= ContentBlockByKey( '0b76dccf-594c-b6dc-1acf-10c4493dcb84'  ) =%%
%%= ContentBlockByKey(  '0b76dccf-594c-b6dc-1acf-10c4493dcb84'  ) =%%
  • ContentBlockById
// double quote

%%=contentblockbyid("1234")=%%
%%=ContentBlockById("1234")=%%
%%= ContentBlockById("1234") =%%
%%= ContentBlockById( "1234" ) =%%
%%= ContentBlockById( "1234"  ) =%%
%%= ContentBlockById(  "1234"  ) =%%

// single quote

%%=contentblockbyid('1234')=%%
%%=ContentBlockById('1234')=%%
%%= ContentBlockById('1234') =%%
%%= ContentBlockById( '1234' ) =%%
%%= ContentBlockById( '1234'  ) =%%
%%= ContentBlockById(  '1234'  ) =%%
  • ContentBlockByName
// double quote
%%=contentblockbyname("Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue")=%%
%%=ContentBlockByName("Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue")=%%
%%= ContentBlockByName("Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue") =%%
%%= ContentBlockByName( "Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue" ) =%%
%%= ContentBlockByName( "Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue"  ) =%%
%%= ContentBlockByName(  "Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue"  ) =%%

// single quote

%%=contentblockbyname('Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue')=%%
%%=ContentBlockByName('Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue')=%%
%%= ContentBlockByName('Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue') =%%
%%= ContentBlockByName( 'Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue' ) =%%
%%= ContentBlockByName( 'Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue'  ) =%%
%%= ContentBlockByName(  'Content Builder\Release 2 - BUILD\Content Blocks Library\NEW\03. Header and banner\Referred contentblock\RS_Dev_Header_blue'  ) =%%

JoernBerkefeld avatar Apr 18 '24 08:04 JoernBerkefeld