In the button code, the line
dog.colMrk__c = "{!Birth_Record__c.Characteristics__c}";
causes an error "Unexpected token ILLEGAL" when there are separate lines in the Characteristics field. Is there a way around this? Both fields are Long Text Area.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var pupIn = "{!Birth_Record__c.dog_Name2__c}";
if (pupIn != "") {
alert("A dog record has already been created for this birth record. Please click the link next to Puppy Name to view that record.")
}else{
var dog = new sforce.SObject("Dog__c");
dog.Name = "{!Birth_Record__c.Name}";
dog.sex__c = "{!Birth_Record__c.Gender__c}";
dog.Dame__c = "{!Birth_Record__c.Dame_ID__c}";
dog.Sire__c = "{!Birth_Record__c.Sire_ID__c}";
dog.colMrk__c = "{!Birth_Record__c.Characteristics__c}";
dog.Breed__c = "{!Birth_Record__c.Breed__c}";
var by = "{!YEAR( DATEVALUE(Birth_Record__c.Birth__c) )}";
var bm = "{!MONTH( DATEVALUE(Birth_Record__c.Birth__c) )}";
if (bm.length == 1){
bm = "0"+bm;
}
var bd = "{!DAY( DATEVALUE(Birth_Record__c.Birth__c) )}";
if (bd.length == 1){
bd = "0"+bd;
}
var b = by+"-"+bm+"-"+bd;
dog.birthdate__c = b;
var result = sforce.connection.create([dog]);
if(result[0].getBoolean("success")){
var nextPg = result[0].id;
var newRecords = [];
var c = new sforce.SObject("Birth_Record__c");
c.id ="{!Birth_Record__c.Id}";
c.dog_Name2__c = result[0].id;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location = "/" + nextPg;
}else{
alert('Could not create record '+result);
}
}