[SalesForce] Updating Salesforce Date field with MC AmpScript

I have not been successful in updating a Salesforce Date or Date/Time field from AMPScript. I've tried different formats but no success in either creating a new record or updating a existing record. I've also tried Standard field vs customs fields and date fields vs. date/time fields.

set @date1 = Format(Now(),"YYYY-MM-DDThh:mm:ssZ")
set @date2 = Format(Now(),"YYYY-MM-DD")
set @date3 = Concat(DatePart(Now(),"Y"),"-",DatePart(Now(),"M"),"-",DatePart(Now(),"D"),"T00:00:00.000Z")

set @id= CreateSalesforceObject("Task", 5, "WhatId", @OpptyId, "WhoId", @ContactId, "Subject", "DATE1", "Status", "(3) Closed", "ActivityDate", @date1)

Best Answer

The date value needs to be either "yyyy-MM-dd" or "iso" format. But, are you sure none of the other values passed in your function are causing issue?

For testing purposes, I would recommend creating a call with as few parameters as possible. Either of the following ampscript values should work as your ActivityDate value.

set @date1 = FormatDate(Now(),"YYYY-MM-DD")

or

set @date1 = FormatDate(Now(),"iso")
Related Topic