How to substitute an end of line character from Salesforce Text Area field - salesforce

I am using a text area field in Salesforce as a RecipientNote for a Docusign envelope created using a custom button in Salesforce.
The syntax below handles any commas or special characters, but I'm unable to find the correct syntax to preserve any linebreaks in the Program_Exception_Notes__c field.
;RecipientNote~{!JSENCODE(URLENCODE(SUBSTITUTE(Sales_Program_Info__c.Program_Exception_Notes__c,",","_COMMA_")))}
I have tried the following but none worked. Any ideas?
'{!SUBSTITUTE(JSENCODE(URLENCODE(SUBSTITUTE(Sales_Program_Info__c.Program_Exception_Notes__c,",","_COMMA_"))),"%0D%0A","\\n")}'
'{!JSENCODE(URLENCODE(SUBSTITUTE(SUBSTITUTE(Sales_Program_Info__c.Program_Exception_Notes__c,"\r\n","\\n"),",","_COMMA_")))}'

I would process your text in a couple of steps in jscript.
first break the text into an array of string lines
escape characters you are looking to correct
then reassemble using the "\n" when you put it back together into a var
Then after all that, URL and JS encode that string variable.

Related

URI malformed, cannot be parsed - while connecting to mongdb using MongoDB Compass connection string

I'm trying to connect to mongoDB with the new password with special char as shown in the screenshot. It gives error as URL malformed due to special character in it.
Initially I was able to connect with normal password.
I tried to add escape characters in password with no luck.
Does anybody have came across this situations or know the solution? Any leads highly appreciated[![enter image description here][1]][1]. Thanks.
Click on the Fill in connection fields individually then input the fields.
It will create the URI with escaped characters for you.
If your password includes special characters you need to encode all special characters. you can find it on this link: https://www.w3schools.com/tags/ref_urlencode.asp

Remove extra brackets from JSON call in Integromat

I am running a HTTP call to bring back data in JSON format but this is bringing through an extra set of square brackets that is causing issues when i am trying to recognise the array. See screen shots.
I can remove the extra set manually in a JSON editor but need to try and find a way of doing this automatically as part of my call.
I am running the call through Integromat and have looked at using Regex but couldn't find the correct code combinations.
Any help or advise much appreciated.
You can use the replace function and insert the brackets that need to be found using regex pattern making sure you denote the bracket at the starting position and the bracket at the end of the string to be replaced with emptystring
Don't check "Parse Response" in HTTP Request module.
That way Data will be returned as long text
Use "Text Parser"'s "Replace", look for ^[|]$ and replace it with emptystring. Make sure you check "Global Match", otherwise it will only do to the first match only=[
3.Then just Parse Json from parsed(replaced) text
I think this article will help.
https://medium.com/#petr.hnilica/json-in-integromat-how-to-create-an-array-from-collections-with-the-same-structure-2991b985e03e

Add blank line between two lines of text in webcal event's description

How to add blank line between two lines of text in webcal event's description? This \n\n doesn't work.
It might help if you would provide a full iCalendar stream but, assuming you encoded them correctly, using "\n" is the only way to express intentional line break. Did you try to display your event using different clients ?

Can you concatenate RTF in a Crystal Reports formula Field

I'm currently building an application that generates a separate letter for each user in the dataset. The letter contents are managed through a vb.net application and their RTF format saved to a database. When the letter is created, all the content is pulled from the database to form the letter using vb.net logic.
Once compiled it was sent as a parameter to Crystal. This worked great, setting the field text interpretation to RTF allowed proper RTF viewing.
The client has decided that they would instead like to make changes to the logic (if statements that compile the text) within Crystal.
So what I did was create a blank dataset with a bunch of columns and filled those columns with the RTF (Ordered by ID so the values will never change unless a paragraph is deleted and there is no option for this). This would allow me to build an RTF string by going {table.1} + {table.2} etc...
This is where the problem is. When building an RTF string in a Formula (Using + or &) it only displays the first RTF entry. If I switch the formula to no interpretation, I can see the RTF for the entries written out with all their content so I know it’s there. I also manually combined the RTF in the formula field and had the same issue.
StringVar output;
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a first test }";
output := output & "{\rtf1\ansi\ansicpg1252\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}\viewkind4\uc1\pard\lang1033\f0\fs23 this is a second test \par\par}";
Output
At this point I am unsure if there is a way around this other than moving all the text to separate Formula fields within crystal itself and then combine. This would mean if they wanted to change text it would have to be done within crystal. I would rather not go this route so I’m looking for opinions and suggestions.
Crystal does support RTF however it needs to be fully formed within the first occurance of an RTF entry. In my question it shows two separate COMPLETE RTF entries. As the entries all have the RTF ID tags this will not be possible. The same issue would occur if you copied the above text into a text editor and saved it as RTF. You would only get the first line. This doesnt explain why it works as a parameter and not a formula but its likely how each are evaluated and the later (parameter could loose support in the future).
To Properly pass RTF to crystal you will need to two Rich text box objects. One being a temp box and the other being the builder box and only selecting the formatted text, not the entire RTF content. An example of this can be found at:
http://moneybaron.org/2011/08/23/vb-net-merge-rtf-documents/
Aside from some hacks such as removing the closing brace from the RTF string or rebuilding the RTF table are also avaliable however removing the brace could lead to an unsupported configuration and rebuilding can get messy really quick.
Hope this helps!!

Saving new Lines in database and Json

I have this problem:
I have an HTML textarea which is filled by the user. (And he can press The enter button to go on a new line).
Then I take The value of The textarea using the command:
document.getElementById("textareaCommento")
And I pass The value to the servlet using an XmlHttpRequest.
In The servlet I save this value in a database.
Since this point I have no problems...
Then, in another part I want to get The values from The database. Using a servlet I make this query
Select * from comments
And I transform the results in json. Here I have The problem... The newline character makes my JSON string invalid. For example:
"Comment":"hello
Word"
How can I do?
Thanks in advance!
You have to replace the \n character from database to something like <br/>
For the replace see replace \n and \r\n with <br /> in java
this CSS worked for me,
white-space: pre-line;
You should be able to url encode your values so hello world would actually become "hello%20world", to do it in java see here:
Encoding URL query parameters in Java
To do it in javascript see here:
Encode URL in JavaScript?

Resources