Update Salesforce Sales and Service Cloud records directly from Marketing Cloud using AMPscript and Automation Studio, enabling one-way bidirectional data sync.
git clone https://github.com/MarketingThibs/update-sf-w-ampscript.gitThis skill enables Marketing Cloud users to update Salesforce Sales Cloud and Service Cloud records using AMPscript Salesforce Functions within Automation Studio. Since Marketing Cloud Connect doesn't support bidirectional synchronization, this approach uses a data extension populated by SQL or automated filters, combined with an AMPscript HTML content block executed in a Script Activity. The solution supports scheduled automations that loop through matching records and update specific Salesforce object fields using the UpdateSingleSalesforceObject function. Teams managing cross-cloud data workflows benefit from this method to automate field updates, status changes, and link generation without manual intervention.
Populate a data extension with rows to update using SQL or automated filters. Create an HTML Content Block with your AMPscript code that uses lookuprows and a for loop to iterate through records and call UpdateSingleSalesforceObject for each field update. Reference the content block in a Script Activity using Platform.Function.ContentBlockByID, then add the Script Activity to an automation and set your desired schedule frequency.
Automatically update Salesforce account status based on Marketing Cloud campaign engagement
Sync encrypted tracking links from Marketing Cloud to Salesforce custom fields
Update opportunity records in Salesforce triggered by Marketing Cloud automation events
Populate Salesforce contact fields with personalized data from Marketing Cloud daily runs
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/MarketingThibs/update-sf-w-ampscriptCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Update Sales/Service Cloud records from Marketing Cloud using AMPscript. [COMPANY] is [INDUSTRY]. Here is the [DATA] to update: [DATA]. Use Automation Studio to ensure the updates are processed efficiently. Provide the AMPscript code to accomplish this task.
```ampscript
%%[
VAR @rows, @row, @rowCount, @email, @firstName, @lastName, @company, @industry
SET @rows = RetrieveSalesforceObjects('Contact', 'Id, Email, FirstName, LastName, Company__c, Industry__c', 'Email', '=', '=')
SET @rowCount = rowcount(@rows)
FOR @row = 1 TO @rowCount DO
SET @email = field(@rows, 'Email', @row)
SET @firstName = field(@rows, 'FirstName', @row)
SET @lastName = field(@rows, 'LastName', @row)
SET @company = field(@rows, 'Company__c', @row)
SET @industry = field(@rows, 'Industry__c', @row)
UPSERTDATA('Contact', 1, 'Email', @email, 'FirstName', @firstName, 'LastName', @lastName, 'Company__c', @company, 'Industry__c', @industry)
NEXT @row
]%%
```Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan