Hi All,
We are trying to create a salesforce ticket using the form data from Identitynow by passing http JSON request body.
The issue is with one of the form fields which is text area field that allows multiple rows to enter, when ever an end user typed one line data and hit enter give some more data in the second line, while creating salesforce ticket it is throwing an error stating “Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character '\\n' in string literal (type: Error Parsing Input, retryable: false): Unable to parse input as JSON, please ensure it is syntactically correct. (type: Error Parsing Input, retryable: false): invalid character '\\n' in string literal (type: SyntaxError, retryable: true)"}”
the json path we are passing for the particular text field in http request body is $.trigger.formData.textfieldname
.
Any one has any idea why we are facing the issue with multiple rows field in text area?
Hello @ShireeshaC2024!
Kindly verify your form field inputs with the above given documentation. Do not hesitate to reply if you are facing any further issues with the forms!
Thanks, Vasanth
@VasanthRam , Thanks for the reply.
It is Text Area field where user enters multiple lines of data, when user enters multiple lines of data salesforce ticket creation is failing with the error " (type: Error Parsing Input, retryable: false): invalid character ‘\n’ in string literal"
Here is the screen shot of the configs of the text area field.
Kindly ensure that the number of lines entered in the text area field matches the number of rows entered in the configs of the text area field. Currently we can enter upto 20 lines of text in a single text area field I guess. In the above shown drop down list box from the text area field configs of forms, you will be able to select till 20 rows. If this is fine then i guess the error should be of some other reason.
Regards, Vasanth
Yes, the configuration is correct as we have given the number of rows in text area element as 2 and entered two lines in that particular field.
For salesforce ticket creation we are passing this form field data to http request body with json path expression as “$.trigger.formData.notesCS” in another workflow (notesCS is the technical key of the textarea field in the form with 2 rows). The ticket creation workflow got failed because of multiple rows in that field, but when I entered some text data in the same text area field in the same line by including any seperator character or even the space , the execution of the workflow is success, and it is sending the data to salesforce for ticket creation, so we came to conclusion that JSON path is not able to read multiple rows in that field as there is no line break indication or something like that.
Is there any way to pass such multiple rows field to salesforce using JSON path expression?
Try this:
Instead of entering data in the text field like this:
Line 1
Line 2
Enter data using break tag as each separator of line like:
It worked for me.
Hope this is helpful to you…
@VasanthRam If we give the data as you mentioned above, in the salesforce ticket it is coming along with the line break tag that too in a single line. However, end user will enter the data in multiple lines, in exact way it should send that data to salesforce in multiplelines(depends on how they want the data to be entered), and have to handle that kind of data to send properly to salesforce. Am uploading the screenshot of salesforce ticket that got created if we give
tag,. So this salesforce ticket is creating by the JSON path of that particular text area field , that we are providing in the http request body of workflow. And the JSON path we are sending is $.trigger.formData.notesCS.
What is occurring is that the when the user add text to the form field with multiple lines, the resulting formdata variable contains new line characters that do not escape properly when the HTTPRequest attempts to do the Variable substitution for the json body.
For example, lets say the user enter the following data into the Form Field “requestLinesData” in the format of
Line 1
Line 2
Line 3
the resulting variable’s value becomes this when passed into the Workflow Form Submitted Trigger:
Line 1 \n Line 2 \n Line 3
In the following HTTPRequest Step, if the Request Body has the following value set in the UI
{
“Request_Type”:“Add”,“Description”:"Requester Details \nRequest Lines: {{$.trigger.formData.requestLinesData}}
}
the system will process this by escaping all of the values so that the jsonRequestBody in the workflow processing would become:
{
\“Request_Type\”:\“Add\”,\“Description\”:\"Requester Details \\nRequest Lines: {{$.trigger.formData.requestLinesData}}
}
Note: This formatting of the Request body is not visible in the script you can download from the UI, but is visible in the execution log for the workflow.
Now, when the variable Substitution happens, this value becomes:
{
\“Request_Type\”:\“Add\”,\“Description\”:\"Requester Details \\nRequest Lines: Line 1 \n Line 2 \n Line 3
}
Reviewing the substitution, we see that it is NOT escaped like the other values. What appears to occur here is that when the test is trying to parse this as JSON, it is hitting the “\n” and seeing it as an actual line break and thus breaking the parsing.
To account for this, you can use a Define Variable Operator to read in the formData variable, use the Replace option to change the “\n” to “\n” and then pass that variable in instead of the original form data field.
@gmilunich the approach you mentioned resolved my issue. Thank you!
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.