Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1270 add method replaceReference to find & replace contentBlockByX with one of the other options #1353

Conversation

JoernBerkefeld
Copy link
Contributor

@JoernBerkefeld JoernBerkefeld commented Jun 2, 2024

PR details

What changes did you make? (Give an overview)

Further details (optional)

TODO: documentation & self-check of code

Checklist

…to-findreplace-contentblockbyx-with-one-of-the-other-options

# Conflicts:
#	types/mcdev.d.js
…to-findreplace-contentblockbyx-with-one-of-the-other-options
…to-findreplace-contentblockbyx-with-one-of-the-other-options
@JoernBerkefeld JoernBerkefeld added this to the 7.0.0 milestone Jun 2, 2024
@JoernBerkefeld JoernBerkefeld self-assigned this Jun 2, 2024
@github-actions github-actions bot added the enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" label Jun 2, 2024
@JoernBerkefeld JoernBerkefeld added c/asset COMPONENT c/journey COMPONENT c/script COMPONENT c/senderProfile COMPONENT c/triggeredSend COMPONENT labels Jun 6, 2024
@JoernBerkefeld
Copy link
Contributor Author

JoernBerkefeld commented Jun 6, 2024

Documentation

https://github.com/Accenture/sfmc-devtools/wiki/06.b-~-Standard-Commands/_edit

replaceContentBlock

Command: mcdev replaceContentBlock <--bu business unit> <--to 'key' | 'name' | 'id'> [--metadata type] [--from 'key' | 'name' | 'id'] [--skipRetrieve] [--skipDeploy] [--refresh]

Alias: mcdev rcb

This replaces ContentBlockByName, ContentBlockById, or ContentBlockByKey with your chosen method. It works for Ampscript and the "Platform.Function."-prefixed SSJS alternatives. It retrieves specified metadata to ensure it parses the latest server versions, prepares the update locally, and then redeploys the metadata.

--bu
Contrary to older methods, replaceContentBlock requires you to define the target BU via the --bu parameter instead of just naming it directly after the command itself. That gives you a bit more flexibility in how you write your commands, but it makes no difference otherwise.

--to
This defines which function you want your code to be converted to use. Possible values: "name", "id", "key".

--metadata (optional)
Set the types (or even type and keys/ids/names) that you want to fix. If omitted, all supported types will be updated - unless they are not listed in your mcdev config for retrieval.

--from (optional)
You may choose to limit what methods get swapped out by defining the --from parameter in case you want to keep one but swap out the other. By default, --from is set to whatever you did not choose for --to. Example: --to key means that --from is auto-set to "name id" and hence ContentBlockByName and ContentBlockById will be replaced with ContentBlockByKey. Any other combination, of course, also works. Possible values: "name", "id", "key".

--skipRetrieve (optional)
If you are absolutely sure you have the latest version of the code already downloaded or you want to override the server versions for some other reason then this option allows you to run rcb directly on your local code and skip the otherwise mandatory retrieve in the beginning. You will however still see that caching is conducted from the server, because Ids/ObjectIds are typically not saved in your downloaded JSONs.

--skipDeploy (optional)
With this option you enable dry-run mode, allowing you to review the deployment package carefully. Keep in mind that changes are made to your files in the retrieve-folder and not in the deploy-folder. At the end of execution, rcb will acknowledge dry-run mode and provide you with a one-liner to execute the targeted deploy for changed files once you are ready.

--refresh (optional)

This is the same option already available for deploy. It only works if you did not use the --skipDeploy option. See deploy docs for more details.

Example:

mcdev rcb --bu MyProject/DEV --to key
mcdev rcb --bu MyProject/DEV --to key -m senderProfile
mcdev rcb --bu MyProject/DEV --to name -m journey --skipDeploy
mcdev rcb --bu * --to id -m triggeredSend -m script -m asset 
mcdev rcb --bu * --to key --from name -m asset --refresh
mcdev rcb --bu * --to key -m "asset:key1" --refresh
mcdev rcb --bu MyProject/DEV --to key automation --skipRetrieve --skipDeploy
mcdev rcb --bu MyProject/* --to key journey --skipRetrieve

lib/index.js Outdated Show resolved Hide resolved
@JoernBerkefeld JoernBerkefeld merged commit c59b169 into develop Jun 7, 2024
8 checks passed
@JoernBerkefeld JoernBerkefeld deleted the feature/1270-add-method-replacereference-to-findreplace-contentblockbyx-with-one-of-the-other-options branch June 7, 2024 07:03
@JoernBerkefeld JoernBerkefeld mentioned this pull request Jun 7, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/asset COMPONENT c/journey COMPONENT c/script COMPONENT c/senderProfile COMPONENT c/triggeredSend COMPONENT enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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