0

We're looking for example AMPSCRIPT code that can help us convert our Event Objects STARTDATETIME field to the correct Day/Time. Thank you everyone!

The use case is that we have an email that notifies a client of a pending appointment scheduled by a sales rep. In some instances, the appointment is off one day as the timezone conversion is off 7 hours. The date is coming in as GMT. So the customer sees the appointment as happening the next day if the appointment is set to happen after 5pm MST.

%%[

/* AMPscript pulls in the values associated with the email subscriber from Salesforce */
SET @Id = [Event:WhoId] /* _subscriberkey is a system field */
/*SET @WhoId = Event:WhoId*/
/*SET @ClientRow = RetrieveSalesforceObjects("Contact", "FirstName", "Id","=",@Id)*/

SET @FirstName = [Event:Who:Contact:FirstName] 
SET @StartDate = [Event:StartDateTime]
SET @ClientLocalStart = [Event:Client_Local_Start_Time__c]
SET @OwnerID = [Event:What:Opportunity:OwnerId]
SET @OwnerRow = RetrieveSalesforceObjects("User","NMLSNumber__c, Name, Phone, MobilePhone, FirstName, Fax, Email, Bio_Link__c", "Id","=",@OwnerId)

IF RowCount(@OwnerRow) > 0 THEN 

  SET @NMLSnumber = Field(Row(@OwnerRow,1),"NMLSNumber__c")
  /*SET @LOFirstName = Field(Row(@OwnerRow,1),"FirstName")*/
  SET @LOFullName = Field(Row(@OwnerRow,1),"Name")
  SET @LODirect = Field(Row(@OwnerRow,1),"Phone")
  SET @LOMobile = Field(Row(@OwnerRow,1),"MobilePhone")

  IF Length(@LOMobile) > 10 THEN
    SET @LOMobile = Substring(@LOMobile,4,10)
  ENDIF

  SET @LOFax = Field(Row(@OwnerRow,1),"Fax")
  SET @LOEmail = Field(Row(@OwnerRow,1),"Email")
  SET @LOBioLink = Field(Row(@OwnerRow,1),"Bio_Link__c")

ENDIF

]%%
0

You can use the DATEADD() function to modify the hours. Display the @LocalDate in the email.

SET @TimeZoneModifier = -7
SET @LocalDate = DATEADD(@ClientLocalStart,@TimeZoneModifier,"H")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.