Skip to content
| Marketplace
Sign in
Visual Studio Code>Snippets>AMPscript code snippetNew to Visual Studio Code? Get it now.
AMPscript code snippet

AMPscript code snippet

MarketingThibs

|
6,917 installs
| (1) | Free
AMPscript code snippet auto completion VS extension for Salesforce Marketing Cloud Users
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

AMPscript Code Snippets

To help you coding with AMPscript for Salesforce Marketing Cloud : as you type get proposed system strings and other functions.

How to ?

  1. Prerequisite : having the AMPscript syntax highlighting extension
  2. When start typing the AMPscript functions and system strings names, press enter to auto-complete your code ampscript-snippets
  3. Press cmd + shift + p and then >insert snippet to review all the snippets available. Press enter to insert one ampscript-snippets2 4.When previewing the snippets, click on i to see the whole description of the different functions

Tips 💡

When editing and AMPscript (.amp file or with AMPscript Syntax), type:

  • code to insert an code block
  • comment to insert
  • if to have basic if statement options
  • for loop to have a sample of loop

Release Notes

1.0.4

  • Initial release

1.0.5

  • Updated Readme file

1.0.6

  • Bug fixing (typos)

1.0.7

  • added better description for functions
  • added new functions (Microsoft CRM, API and a few others...)
  • added a snippet called: code block AMPscript
    %%[
    
    ]%%
    
  • added a snippet called: for loop
    %%[
    set @lookupDeRows = lookuprows("MyDe","SomeField","SomeValue")
    set @nbLookupDeRows = rowcount(@lookupDeRows)
    for @i = 1 to @nbLookupDeRows DO
        set @loopDeRow  = row(@lookupDeRows,@i)
        set @someField1 = field(@loopDeRow,"someField1")
        set @someField2 = field(@loopDeRow,"someField2")
    ]%%   
    %%=v(@someField1)=%%<br>
    %%=v(@someField1)=%%<br>
    %%[next @i]%%
    
  • added a snippet called: if elseif inline statement
    %%[
    
    ]%%
    
  • added a snippet called: if elseif statement for external blocks
    %%[if @myvar == "this" then]%%
        /* do this */
    %%[elseif @myvar == "that" then]%%    
    /* do that */
    %%[else]%%
        /* do nothing */
    %%[endif]%%
    
  • added a snippet called: if contains inline statement
    %%[
    /* Set the value to check */ 
    Set @Value= "Indianapolis" 
    /* Set the string to check */ 
    Set @String = "Welcome to Indianapolis, we hope you enjoy your stay!" 
    /* Does it match; ; if no match, output of IndexOf(1,2) will be "0" */ 
    if IndexOf(@String,@Value) > 0 then 
        Set @Output = "How was your stay in Indianapolis" 
    else 
        Set @Output = "Where would you like to stay?" 
    endif 
    ]%%
    
  • added a snippet called: if empty inline statement
    %%[
    if @myvar == "this" then
        /* do this */
    elseif @myvar == "that" then
        /* do that */
    else
        /* do nothing */
    endif
    ]%%
    
  • added a snippet called: hidden code block AMPscript
    %%[
    /* MyAMPscriptBlock <div style="display:none"> */
    HereIsTheAMPscriptCode
    /*</div>*/ 
    ]%%
    
  • added a snippet called: debug catch error AMPscript block
    <script runat="server" type="text/javascript">
    Platform.Load("Core", "1.1.1");
    try {
    </script>
    %%[ 
    /* AMPscriptHere */ 
    ]%%
    <script type="text/javascript" runat="server">
    }
    catch (e) {
    Write("<br>AMPscript Error Message: " + e);
    }
    </script>
    

Made with ❤ by Marketing Thibs

Discover more Salesforce Marketing Cloud on GitHub

Buy Me A Coffee

Enjoy

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft