You need to sign in to do that
Don't have an account?
Don Pierce
Concatenating text and textarea fails in javascript
I am trying to concatenate two fields and insert into a Note.
It works fine when I use text but fails when I try to use a textarea
InstrumentName__c is a text(255) field and IntrumentProblem_c is textarea(255)
The following works fine:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = '{!Case.InstrumentName__c}';
result3 = sforce.connection.create([repnew3]);
This will not work:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = '{!Case.InstrumentProblem__c}';
result3 = sforce.connection.create([repnew3]);
Is there a conversion process require or does the Note.Body field not accept textarea?
Ultimately I want to concatenate the two as follows:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = 'Problem: ' + '{!Case.InstrumentProblem__c}' + ' Name: ' + '{!Case.InstrumentName__c}';
result3 = sforce.connection.create([repnew3]);
This is being used as a button action on the Case layout.
It works fine when I use text but fails when I try to use a textarea
InstrumentName__c is a text(255) field and IntrumentProblem_c is textarea(255)
The following works fine:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = '{!Case.InstrumentName__c}';
result3 = sforce.connection.create([repnew3]);
This will not work:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = '{!Case.InstrumentProblem__c}';
result3 = sforce.connection.create([repnew3]);
Is there a conversion process require or does the Note.Body field not accept textarea?
Ultimately I want to concatenate the two as follows:
var repnew3 = new sforce.SObject('Note');
repnew3.ParentId = qr.records.Id;
repnew3.Title = '{!Case.Subject}';
// combine
repnew3.Body = 'Problem: ' + '{!Case.InstrumentProblem__c}' + ' Name: ' + '{!Case.InstrumentName__c}';
result3 = sforce.connection.create([repnew3]);
This is being used as a button action on the Case layout.
zxc
sadf
sdf
is now
zxc%0D%0Asadf%0D%0Asdf
So I just did a replace with \r and \n and that resolved the issue.
This is the code:
var teststr = '{!URLENCODE(Case.Instrument_Problem__c)}';
teststr = teststr.replace(/%0D/g, '\r');
teststr = teststr.replace(/%0A/g, '\n');
repnew3.Body = teststr;
result3 = sforce.connection.create([repnew3]);
if(result3[0].success == 'true'){
alert('A new Note was created Successfully.');
}
All Answers
In case related Note ,body doesnot allow Textarea if any html styles are added to it.Once try without giving html style.
if it useful make it as best answer
THanks ,
Ram.
zxc
sadf
sdf
is now
zxc%0D%0Asadf%0D%0Asdf
So I just did a replace with \r and \n and that resolved the issue.
This is the code:
var teststr = '{!URLENCODE(Case.Instrument_Problem__c)}';
teststr = teststr.replace(/%0D/g, '\r');
teststr = teststr.replace(/%0A/g, '\n');
repnew3.Body = teststr;
result3 = sforce.connection.create([repnew3]);
if(result3[0].success == 'true'){
alert('A new Note was created Successfully.');
}