Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 554

AMPScript generating logs but not capturing field value in the CRM

$
0
0

I am using a email interactive form on SFMC. The form has just one field "zip code". Once users enter the zip code and hit submit, it gets captured in a data extension and they are redirected to a cloud page with an AMPScript that updates the CRM with the Zip and creates an interaction log for the contact. While the code generated the interaction logs but the zip code was not updated. When I tried hard coding the zip instead of using @zip, it worked and updated the CRM. When I use @zip, it doesn't store the zip in the CRM. The code I used is

%%[VAR @market, @message, @message2, @message3, @subkeyvar, @rsa, @CaptureContactId, @result, @statusVAR @zip, @contact/* Capture subscriber key and zip code from query parameters */SET @subkeyvar = AttributeValue("_subscriberkey")SET @pageLanguage = QueryParameter("language")SET @zip = QueryParameter("zip")/* Retrieve the Contact from Salesforce using subscriber key */SET @ContactRows = RetrieveSalesforceObjects("Contact","FirstName,Email,Id,LastName,Birthdate,Market__c,Brand__c,Residence__c","Id", "=", @subkeyvar)/* If Contact exists */IF RowCount(@ContactRows) > 0 THEN  VAR @ContactRow, @urlTechnique, @lang, @birthdate, @tptcp, @brand, @location, @IsoCode, @CID  SET @ContactRow = Row(@ContactRows, 1)  SET @FirstName = Field(@ContactRow, "FirstName")  SET @LastName = Field(@ContactRow, "LastName")  SET @contact = Field(@ContactRow, "Id")  SET @email = Field(@ContactRow, "Email")  SET @brand = Field(@ContactRow, "Brand__c")  SET @location = Field(@ContactRow, "Market__c")  SET @IsoCode = Field(@ContactRow, "Residence__c")  SET @birthdate = Field(@ContactRow, "Birthdate")  /* Update Contact with zip code if provided */  IF NOT EMPTY(@zip) THEN    SET @result = UpdateSingleSalesforceObject("Contact",      @contact,"ZipCode__c", /* Custom ZIP field in Salesforce */      @zip    )  ENDIF  /* Define metadata for CaptureContact record */  SET @tptcp = 'account update'  SET @NewsletterType = 'Regular'  SET @source = 'zipcode_enrichment'  SET @dataSource = 'Hygiene'  SET @sourceType = 'Self Registration'  SET @status = 'Validated'  SET @customerIdSourceSystem = 'SALESFORCE'  SET @dataEmailChannel = @email  SET @URL = RequestParameter("PAGEURL")  SET @lang = 'eng'  SET @SourceDetail = @source  /* Retrieve the country ID using the ISO code */  IF NOT EMPTY(@IsoCode) THEN    SET @IsoCountry = RetrieveSalesforceObjects("Country__c","ID,CountryISOCode__c","CountryISOCode__c", "=", @IsoCode    )    IF RowCount(@IsoCountry) > 0 THEN      SET @CID = Field(Row(@IsoCountry, 1), "ID")    ENDIF  ENDIF  /* Create CaptureContact record */  SET @createSfRecord = CreateSalesforceObject("CaptureContact__c", 23,"FirstName__c", @FirstName,"LastName__c", @LastName,"Email__c", @email,"Url__c", "https://abc.com/zip-confirmation","TypeOfTouchpoint__c", @tptcp,"Brand__c", @brand,"Birthdate__c", @birthdate,"Market__c", "USA","Country__c", @CID,"NewsletterType__c", @NewsletterType,"OptinEmailChannel__c", "True","Status__c", @status,"Source__c", @source,"DataSource__c", @dataSource,"SourceType__c", @sourceType,"CustomerIdSourceSystem__c", @customerIdSourceSystem,"PreferredLanguage__c", @lang,"Contact__c", @contact,"TechnicalURL__c", "https://abc.com/zip-confirmation","LegalAge__c", "True","LocationOfResidence__c", @IsoCode,"SourceDetail__c", @SourceDetail,"ZipCode__c", @zip  )ENDIF/* Show confirmation message */IF Length(@createSfRecord) == 18 THEN  SET @message = "Thank you!You’re all set — we’ve got your zip code.Stay tuned!"ELSE  SET @message = "An error has occurred!"  SET @message3 = "Visit our website"  SET @link1 = “abc.com”ENDIF]%%

What am I missing? This code at least generated the logs however, now without changes it displays the error "An error occurred". Please help


Viewing all articles
Browse latest Browse all 554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>