Remove line breaks from a Text field | Community
Skip to main content
New Participant
March 6, 2024
Solved

Remove line breaks from a Text field

  • March 6, 2024
  • 1 reply
  • 3721 views

Is it possible to remove line breaks from within a Text field using a Flow step?
We are using a Text field in a webhook call, and getting a BadRequest error when the field has line breaks and does not adhere to JSON string format.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

It is part of the Payload of the webhook call - the syntax is below.

 

{ "salesOrg": "{{lead.Sales Org:default=edit me}}", "contactId": "{{member.PMCFstring6}}", "accountId": "{{lead.Account Nbr (SFDC):default=edit me}}", "campaignName": "{{member.PMCFstring5}}", "firstName": "{{lead.First Name:default=edit me}}", "lastName": "{{lead.Last Name:default=edit me}}", "fullName": "{{lead.Full Name:default=edit me}}", "email": "{{lead.Email Address:default=edit me}}", "phone": "{{lead.Phone Number:default=edit me}}", "city": "{{lead.City:default=edit me}}", "state": "{{lead.State:default=edit me}}", "zip": "{{lead.Postal Code:default=edit me}}", "country": "{{lead.Country:default=edit me}}", "currencyIsoCode": "{{lead.Lead Currency:default=edit me}}", "company": "{{lead.Company_formUse:default=edit me}}", "profession": "{{lead.Profession:default=edit me}}", "position": "{{lead.Primary Position:default=edit me}}", "leadId": "{{member.PMCFstring7}}", "products": "{{Lead.Web product Interest:default=edit me}}", "inquiryType": "{{member.PMCFstring1}}", "message": "{{Lead.Feedback_txt_long:default=edit me}}", "formId": "{{member.PMCFstring3}}", "formName": "{{member.PMCFstring4}}", "formUrl": "{{member.PMCFstring2}}", "sourceSystem": "{{lead.Lead Source:default=edit me}}" }

 

The fields on the left are SFDC fields. 


You don’t add quotes around the tokens in the payload.

 

JSON encoding takes care of quoting when necessary. It encodes values based on the datatype (string, number, boolean).

1 reply

SanfordWhiteman
New Participant
March 6, 2024
Your question isn't clear: string values don't need to "adhere to JSON string format" because Marketo JSON-encodes strings properly when you have JSON selected in the webhook definition.

It's impossible for stored values to all be valid JSON. That would mean they'd have literal double quotes in the database!
ChadWebb1Author
New Participant
March 6, 2024

Here is the response I got from the target system admin...


I checked the logs of PROD and looks like there is an issue with the "message" tag . Its having multiple line breaks and not adhering to JSON string format  hence you are getting Bad Request. 
Below is the message tag which is coming with multiple line breaks and not adhering to the right JSON Format.
Solution : 
Please replace the line breaks with \n so it adheres to string format ( as shown below)  Post this it should work .
   "message""Please send me a quote for this instrument Roche Cobas Z 480 .\nThanks,\nBin",
SanfordWhiteman
New Participant
March 6, 2024

You need to have Request Token Encoding set to JSON:

There’s no need to make changes to the stored value.