Skip to main content

Salesforce Marketing Cloud : Ampscript in 10 Minutes


Salesforce Marketing Cloud

Ampscript in 10 Minutes





Variables


%%[

Var @a

Set @a = 10

]%%

<h1>%%=v(@a)=%%</h1>


Lookup


Lookup("DENAME",

"EmailAddress",

"SubscriberKey", 

@lookupValue)


LookupRows


set @rows = LookupRows("DENAME","flag", true)

set @rowCount = rowcount(@rows)

if @rowCount > 0 then

  for @i = 1 to @rowCount do

    var @emailAddress, @firstName, @rank

    set @row = row(@rows, @i) 

    set @emailAddress = field(@row,"emailAddress")

    ]%%

    <br>emailAddress: %%=v(@emailAddress)=%%

    %%[  next @i ]%%

%%[ else ]%% No rows found %%[ endif ]%%


InsertDE


This function inserts a row in a Data Extension

InsertDE("DENAME",

"EmailAddress", 

@emailAddress,

"SubscriberKey", 

@subscriberKey)


UpdateDE


This function updates the Data Extension 

UpdateDE("DENAME",1,

"EmailAddress", @emailAddress, 

"Update", @updateDate)




RetrieveSalesforceObjects

This function retrieves fields from a record in a Sales or Service Cloud 

standard or custom object.

set @subdetails = 

RetrieveSalesforceObjects(

   "Contact",

   "LastName,Email",

   "Id", "=", _subscriberKey )




UpdateSingleSalesforceObject

This function updates a record in a Sales or Service Cloud 

standard or custom object.

set @updatedetails = 

UpdateSingleSalesforceObject(

      "Contact",

   @Id,

      "LastName", @lastName,

      "Email", @email)




InvokeExecute

Unsubscribe Management - “ Marketing Cloud API “

set @er = CreateObject("ExecuteRequest")

SetObjectProperty(@er,"Name","LogUnsubEvent")


set @prop = CreateObject("APIProperty")

SetObjectProperty(@prop, "Name", "SubscriberKey")

SetObjectProperty(@prop, "Value", "_subscriberKey ")

AddObjectArrayItem(@er, "Parameters", @prop)

set @invokeStatusObj = InvokeExecute(@er, 

@invokeStatusMessage, @invokeRequestId)


Comments

Popular posts from this blog

Remote Developer Job Sites

Remote Developer Job Sites 1.  https://angel.co/ 2.  https://turing.com/ 3.  https://www.employremotely.com/ 4.  https://www.upwork.com/ 5.  https://www.freelancer.com/ 6.  https://www.pesto.tech/ 7.  https://www.guru.com/ 8.  https://www.fiverr.com/ 9.  https://remotive.io/ 10. Search Remote Jobs on LinkedIn or other such platforms. 11. Sell Code on  https://codecanyon.net/ Lastly, a viable option could be, you can open your own website, display your work and get your own set of clients.

Coding Best Practices

 When it comes to coding, best practices is required to meet Industry Standards. But, what are the best practices and why do you need one. Why to bother ? Well, we have you covered on this. You see more than writing code, a programmer needs to remember that the code base will be accessed by multiple developers in the long run. Associates will come and go. People change frequently, Right ! They change teams. They change companies. Now, developers who are newly assigned a project, think about them. If the code is clean, readable, with proper comments and the right documentation, how great would that be. Nothing can make their lives easier. This is one of the prime factor why coding best practices are followed. Also, writing the code again and again will only increase the size, but not be called efficient. Hence comes, code reusability. To jot it down - 1. Maintability 2. Readability 3. Reusability Now what are the best practices, well, hold on, here you have it below - 1. Proper comm...

Chanakya Niti for Success in Corporate World

 Chanakya Niti for Success in Corporate World  " Before you start some work, always ask yourself three questions - Why am I doing it, What the results might be and Will I be successful. Only when you think deeply and find satisfactory answers to these questions, go ahead." "Learn from the mistakes of others... you can't live long enough to make them all yourselves!! " - Chanakya "A person should not be too honest. Straight trees are cut first and Honest people are screwed first." "Even if a snake is not poisonous, it should pretend to be venomous." "Never make friends with people who are above or below you in status. Such friendships will never give you any happiness." "Education is the best friend. An educated person is respected everywhere. Education beats the beauty and the youth." "An egoist can be won over by being respected, a crazy person can be won  over by allowing him to behave in an insane manner and a wise...