For Marketing Cloud developers who used to and wanted to have the features of IDE, the default browser based editor is a nightmare to edit long scripts. Here comes a savior for those!
Now you can connect your Marketing Cloud with your local Visual Studio Code with a super simple extension – AMPscript by Agadzhanov Sergey.
An actively maintained project (as of this writing) – vscode-ampscript provides us the ability to:
- Utilize the features of Visual Studio Code.
- Connect Marketing Cloud assets with Visual Studio Code:
- Blocks
- Emails
- Templates
- Cloud Pages
- Mobile Messages
- Syntax Highlighting for AMPScript.
- Code and Hover Snippets.
Connecting VS Code with Salesforce Marketing Cloud Instance
Setting up Marketing Cloud
- Login to Marketing Cloud. Make sure you have permission to create packages.
- Go to Setup by hovering your Name Avatar.
- Under the setup section, open Apps > Installed Packages.
- Create a new package by providing a name and description that you desire.
- Click Add Component button at the bottom of the page.
- Select API Integration and click Next.
- Select “Server-to-Server” Integration Type and click Next.
- Select the permissions that you wish. Basically you might need
- Email – Read and Write
- Web – Read, Write and Publish
- Saved Content – Read and Write
- Click Save.
- If you have Business Units in your Marketing Cloud account, (Only available for Enterprise 2.0 tenant)
- Click on the Access Tab
- Make sure the Integration is enabled for the Business Unit you wanted to integrate.
Setting up Visual Studio Code
- Install AMPScript Extension. (Make sure you update your Visual Studio code to the latest)
- Open View > Command Palette.
- Enter
MCFS: Connection Manager
in the Command Palette. - Click on the New Connection from the Connections List section in the page that is opened.
- Copy “Authentication Base URI”, “Client Id”, “Client Secret” and your MID (Business Unit ID) from the Package Page and paste the values in the appropriate fields.
- Click Save Changes.
- Now click Connect to connect to your Marketing Cloud Instance.
I can’t connect, it says error ‘Incorrect MID’.
I have checked several times the MID, Auth, Client Secret and ID, but the error keeps the same.
Any clue?
Thank you
Daniel
LikeLike
That should not be the case, there should be typo or mismatches.
From the code I see this:
if (isNullOrUndefined(mid.match(/^\d+$/g))) {
throw new Error(“Incorrect MID”);
}
https://github.com/Bizcuit/vscode-ampscript/blob/master/src/marketingCloud.ts
If you still face the trouble, you can raise an issue here: https://github.com/Bizcuit/vscode-ampscript/issues. Developer will be happy to touch-base with you.
LikeLike
Hi,
I have raise the issue in github
Before that I have created a login access with postman with the same MID and credentials, and this URI https://xxxxxxxxxxxxxxxxxxxxxxxxx.auth.marketingcloudapis.com/v2/token instead of https://xxxxxxxxxxxxxxxxxxxxxxxxx.auth.marketingcloudapis.com/ and is giving me an status Ok 200
I have seen also that the connection name does not change from My Connection1. I have saved changed, reopen VS and the json has the values I entered but the side bar doesn’t get not even the connection name.
Thank you
LikeLike
This appears something like issue with VS Code, let us see it gets fixed sooner.
LikeLike
How did you solve the issue ?
I have the same problem even though i checked and rechecked all the parameters. I tried deleting the connection and creating a new one but it doesn’t fix the issue :
Unable to read directory “/” Error details: Error: Incorrect MID
LikeLike
Try removing the folder from the workspace in VS Code by right clicking the folder and then reconnect with right credentials.
LikeLike
Are we able to push the changes we make from VSCode Cloudpage content back to Marketing Cloud?
LikeLike
Hmm yes, you should be able to. But that needs to be published to see the changes in live.
LikeLike