You are viewing limited content. For full access, please sign in.

Question

Question

Removing b and br characters when pulling in fields from Salesforce to Forms

asked on March 2, 2018 Show version history

Hello Everyone,

An individual at my org has recently stumbled across this little situation. When pulling our caution field text from Salesforce to Laserfiche. Bolded words and line breaks are being pulled along and "<b>" and "<br>" are being entered in their place. As some of you are aware, forms doesn't like that and we then get an error saying that invalid characters are in the text. Is there a way to css or javascript this into the form to automatically remove those characters when the text is pulled in or when the form is submitted?

We are launching the form and pulling in the characters through a button made on the page layout. 

Below are some snippets of some examples:

here is the caution field in Salesforce. 

This is what the text looks like once pulled into Salesforce. As you can see the whole text is enclosed by <b> for bolded text, and the line break is in there as <br><br>. The apostrophe s ('s) is then inserted as &#39;

 

This is the error we then receive. 

 

Does anyone know a way around this? Or if there is a setting that needs to be switched up within Salesforce?

 

Thanks

0 0

Replies

replied on March 4, 2018

Hi Duane,

You can remove the html tags with custom scripts. Assuming the target field is a multi-line field and has css "target":

  $('.target textarea').change(function(){
    var pulledVal = $('.target textarea').val();
    pulledVal = pulledVal.replace(/<br>/g, '\r\n'); //remove this line if it's not multi-line field or new line is not expected
    pulledVal = pulledVal.replace(/<(.|\n)*?>/g, '');
    $('.target textarea').val(pulledVal);
  });

I have no idea how your "pulling in from Salesforce" is done. If it's through custom script as well, you can add the string replace to your function directly.

0 0
replied on March 5, 2018

Thanks for the input Rui,

 

We are currently using a button on the page layout to pull information in from SalesForce. I've included a snippet of the button below:

 

It essentially matches fields in Salesforce and pulls in information to LF with the fields that are "linked" up to it within the button. 

0 0
replied on March 5, 2018

I had thought it was a button on Forms but your screenshot did not look like for Forms. 

It seems that you have a button somewhere that when clicking on it, it would open Forms New Submission page with presented value passed through URL, right? And in one of the passed values, you would like the value to be updated so html tags would be removed?

If so, the above script should still work. If it does not work for you, can you give me a screenshot of the Forms New Submission page with values?

0 0
replied on March 6, 2018

I think I may just be inserting the code wrong. I've tried altering it a handful of ways but no avail yet. So I have included a snippet of what gets pulled into forms and another snippet of the CSS/Javascript on the form itself, along with the id's of the fields on the form.

 

 

 

Thanks for getting back to me each time Rui

0 0
replied on March 6, 2018 Show version history

The script I put above was Javascript, not CSS, so you don't need to put it in CSS part.

Also: $("#q208").val() won't get the correct value, you need to use $("#q208 textarea").val(); the script need to be wrapped inside the document.ready function. Try it like this:

$(document).ready(function(){
  $('#q208 textarea').change(function(){
  var pulledVal = $('#q1 textarea').val();
  pulledVal = pulledVal.replace(/<br>/g, '\r\n'); //remove this line if it's not multi-line field or new line is not expected
  pulledVal = pulledVal.replace(/<(.|\n)*?>/g, '');
  $('#q208 textarea').val(pulledVal);
});
$('#q208 textarea').change(); //trigger change again after event registered
})

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.