You need to sign in to do that
Don't have an account?
sf consultant.ax380
Use server side SUBSTITUTE function to remove carriage returns and line feeds while within an s-control?
USE CASE
User enters data in text area on standard field (non visual force page) return of save button has been overrriden to call an s-control. .S-control needs to populate the value of the merge field referencing that standard field in a javascript var and append it to the url for an iframe. (Seems simple)
PROBLEM
Darn CRLF's that are embedded in the Merge Field if user hits enter in the text area field cause disasterous results (unterminated string error) when applying the merge field value to a javascript var.
QUESTION
Why have I constantly been unsuccessful in using Substitute to remove the CRLF?? Has ANYONE gotten this to work?
I've read varous other hacks requiring additional presentation logic of hidden form fields or hidden divs working but this is not a read only field. The user is entering this right before the s-control is called. I've heard of maybe run an additonal query either using query or retrieve as opposed to evaling the merge field but this has not seemed to work for me either.
ie. .the below I am using to protect against single and double quotes but I've tried numerous deritives to project against carriage returns and Substitute just doesn't seem to want to do it.
var desc = encodeURI("{! Substitute(Substitute(Case.Description ,"\\","\\\\"),"\"","\\\"")}" );
Any help would be greatly appreciated as I've wasted numerous hours on this. (in any other scenario I would use the full service side power of java to remove unwanted stuff before applying to the javascript var but in the case of Force.com and using an s-control. from my understanding my server side capability in this context is somewhat limited.
Thank you!
Message Edited by sf consultant on 11-26-2008 07:56 AM
Message Edited by sf consultant on 11-26-2008 07:57 AM
Message Edited by sf consultant on 11-26-2008 07:58 AM
User enters data in text area on standard field (non visual force page) return of save button has been overrriden to call an s-control. .S-control needs to populate the value of the merge field referencing that standard field in a javascript var and append it to the url for an iframe. (Seems simple)
PROBLEM
Darn CRLF's that are embedded in the Merge Field if user hits enter in the text area field cause disasterous results (unterminated string error) when applying the merge field value to a javascript var.
QUESTION
Why have I constantly been unsuccessful in using Substitute to remove the CRLF?? Has ANYONE gotten this to work?
I've read varous other hacks requiring additional presentation logic of hidden form fields or hidden divs working but this is not a read only field. The user is entering this right before the s-control is called. I've heard of maybe run an additonal query either using query or retrieve as opposed to evaling the merge field but this has not seemed to work for me either.
ie. .the below I am using to protect against single and double quotes but I've tried numerous deritives to project against carriage returns and Substitute just doesn't seem to want to do it.
var desc = encodeURI("{! Substitute(Substitute(Case.Description ,"\\","\\\\"),"\"","\\\"")}" );
Any help would be greatly appreciated as I've wasted numerous hours on this. (in any other scenario I would use the full service side power of java to remove unwanted stuff before applying to the javascript var but in the case of Force.com and using an s-control. from my understanding my server side capability in this context is somewhat limited.
Thank you!
Message Edited by sf consultant on 11-26-2008 07:56 AM
Message Edited by sf consultant on 11-26-2008 07:57 AM
Message Edited by sf consultant on 11-26-2008 07:58 AM
Can't you use javascript to replace?
var string = "{!SomeMergeField}";
var string2 = text.replace(/[\r\n]/g, "");
Message Edited by Harmpie on 11-26-2008 11:54 PM
Unfortunately I don't think that will work..
The problem isn't so much parsing out the line feeds, the problem is the initial assignment of the merge field to the js value. (it will never get assigned because it causes a double line in the js in the browser.
After entering a value in the long text field such as
Perhaps you could get the value from the DOM or from a URL instead? Then you could use the javascript replacement technique.