You need to sign in to do that
Don't have an account?
AstroCRM
Unterminated String error on Text areas
Hi all,
I am trying to grab the contents from a custom text area field in account and write them (inherit them) to another record type with an scontrol. It all works fine except for when there are line breaksin the field and I haven't been able to work out a function that will let me encode the values of the carriage returns within the text area and write them on the new record.
Could anyone please provide some help on this?
Thanks and best regards.
I am trying to grab the contents from a custom text area field in account and write them (inherit them) to another record type with an scontrol. It all works fine except for when there are line breaksin the field and I haven't been able to work out a function that will let me encode the values of the carriage returns within the text area and write them on the new record.
Could anyone please provide some help on this?
Thanks and best regards.
Are you sure it's line breaks and not embedded quotes or double quotes?
http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&message.id=121
Good luck, Steve.
Guys, I am going to try the solution. Thanks for your help, much appreciated. :)
Here is part of the code. Any help would be highly appreciated:smileyindifferent:
{
'<textarea id="address" style="display: none">{!Account_Site_Address_Street}</textarea>';
}
}
}
function myCreate(objType, recType, currencyCode){
var obj= new Sforce.Dynabean(objType);
var objArray=new Array(1);
obj.set("Name","{!Account_Name} (child)"); //naming convention
obj.set("ParentId","{!Account_ID}"); //Associate the new record with the LE Account
obj.set("CurrencyISOCode",currencyCode); //inherited
obj.set("Country__c","{!Account_Country}"); //inherited
obj.set("Time_Zones__c","{!Account_Time_zones}"); //inherited
obj.set("Language__c","{!Account_Language}"); //inherited
obj.set("ShippingStreet", alert(document.getElementById("address").value); //inherited
obj.set("RecordTypeId", recType);
obj.set("Validation__c", "TRUE");
objArray[0]=obj;
//alert (obj.className);
var objSaveResult = sforceClient.Create(objArray)[0];
if (objSaveResult.success == true) {
opener.location.replace("/" + objSaveResult.id + "/e?retURL=%2F" + objSaveResult.id); //redirect to the newly created record
//window.close();
setTimeout("window.close();",2000);
}else{
//alert('KO!' + typeof objSaveResult);//object
//alert('KO' + objSaveResult[0].message);
document.getElementById("wait").innerHTML=objSaveResult.toString();
}
}
//-->
Well, last but not least, there is always another alternative.
Since you've also got "{!id}" at your disposal, you can always issue a retrieve on the current ID and use the value from there instead of using the "{!Account_Site_Address_Street}". E.G. (assuming it's an account field.)
var tmp = sforceClient.retrieve('Account_Site_Address_Street__c','Account','{!id}'); //
obj.set("ShippingStreet",tmp.get("Account_Site_Address_Street__c"));
Steve. (going to sleep)
By the way guys, none of the solutions I have tried work. I think by now you have most likely realized I am not an expert on this so, if by any chance you might have more ideas, they'd be rather appreciated.
Thanks.
:smileysad:
var tmp = sforceClient.retrieve('Site_Address_Street__c','Account','{!id}'); //
obj.set("ShippingStreet", tmp.get("Site_Address_Street__c"));
Still get the bad link error:smileymad:
You are essentially declaring a string literal that contains a script tag. ???
You html should follow this structure.
Code:
Yeah that is a bad error from my part. I am a real novice to this and I am finding it quite difficult. It's not that I haven't tried though, this must be my 7th hour today trying to get this to work with no avail. I was just wondering if I post the whole code you guys might have any ideas that could point me to the right direction. Any help at all
Code:
I'll take a look at it tomorrow. I'm sure we can get this resolved, after all, it's not brain surgery!
:smileywink:
The code below might need to be tweaked to work for you but should be closer. Also, it's not a good idea to replace the innerHTML of the body tag.
Code:
I did try this solution before
Code:
But unfortunately it gives me the error "Object Required"
Following your comment on ShippingStreet:
Code: Is correct because if I merge any single lined field (e.g {!Account_ShippingCountry}) into it, it works fine.
It is only when I have:
Code:
And it is multilined, that I get the unterminated string constant error.
Again, I do thank you for your efforts and help. If you have any other idea it'd be very welcome indeed. You are a top guy:)
Cheers
I realize we're five years later, but I'm having the same problem inside a custom button/link with some javascript.
Essential, if my lead's Street is
123 Main St
Then {!Lead.Street} expands perfectly inside JavaScript. However if the Street is
123 Main St.
Suite 100
Then I get a page error clicking on the link, complaining of an unterminated string constant.
The JavaScript looks something like: