- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2022 08:20 AM
Building the encoded templateFields string for the Global Update Record in a client script (api.data.update_request_record.execute). I'm doing fine with short strings and sysIds. I need to know how I can encode multiline strings (textarea content) and dates--those are erroring. It works fine when I don't add those, but that does not get me to where I need to get. Are there function samples or documentation (or someone's video) for how to encode/prep them somewhere? Or can you tell me, please.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2022 11:34 AM
Processing a textarea for api.data.update (or create, I'll presume). This preserves the line breaks to the data long String field. The backslash and caret were the only special characters I could find that need escaping, YMMV--I tested everything obvious but not the extended character sets. This works well as far as getting to the database. I am annoyed about having to spend a lot of time figuring out how to make a Save work when the functionality should be built into it, but so it goes. To be able to use my text in the email text for a flow without again losing the carriage returns, there is another step. I can apparently only put one code block in a post, so that will be a following reply.
function fixTextAreaForWrite(inputText) {
let workingText = inputText;
// Backslash MUST BE FIRST
workingText = workingText.replace(/\\/g, "\\\\");
// Carriage returns
workingText = workingText.replace(/(\r\n|\r|\n)/g, "\\n");
// Cannot make caret work, just remove
workingText = workingText.replace(/\^/g, "");
return workingText;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2022 11:34 AM
Processing a textarea for api.data.update (or create, I'll presume). This preserves the line breaks to the data long String field. The backslash and caret were the only special characters I could find that need escaping, YMMV--I tested everything obvious but not the extended character sets. This works well as far as getting to the database. I am annoyed about having to spend a lot of time figuring out how to make a Save work when the functionality should be built into it, but so it goes. To be able to use my text in the email text for a flow without again losing the carriage returns, there is another step. I can apparently only put one code block in a post, so that will be a following reply.
function fixTextAreaForWrite(inputText) {
let workingText = inputText;
// Backslash MUST BE FIRST
workingText = workingText.replace(/\\/g, "\\\\");
// Carriage returns
workingText = workingText.replace(/(\r\n|\r|\n)/g, "\\n");
// Cannot make caret work, just remove
workingText = workingText.replace(/\^/g, "");
return workingText;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 10:13 AM
This works to escape the ^ in the string
workingText = workingText.replace(/\^/g, "\\^");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2023 09:46 PM
I also processed a textarea with api.data.update (and create) data resource execute for my "comment" field. I used the data resource in Script mode to encode the textarea value with the encodeURIComponent( ) function. Below is example script code for my "Update" data resource execute event:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2024 08:04 AM
I'll be doing an update to that application (that contains the update we're talking about) soon. I'll definitely test this out to see if it works for me. Thank you.