function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Gautier Swiercz 7Gautier Swiercz 7 

Problem on custom button create note record

Hi,

Here my custom button code : 

"{!REQUIRESCRIPT('/soap/ajax/22.0/connection.js')}

var not = new sforce.SObject('Note');

not.Title = '{!Opportunity.StageName}' + '{!Opportunity.Name}';
not.OwnerId = '{!Opportunity.OwnerId}';
not.ParentId = '{!Opportunity.Id}';

result = sforce.connection.create([not]);

if(result[0].getBoolean('success')){
window.location = '/' + result[0].id + '/e';
}else{
alert('Could not create record '+result);
}"

This custom button do that : 
- create a new note related to my current opportunity
- Then, load a new page, with the current note, with the correct title, but when i click on "save", nothing.

Can anyone help me ? 
RbnRbn
Hi Gautier,

Please find the below code:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var not = new sforce.SObject("Note");
not.Title = '{!Opportunity.StageName}' + '{!Opportunity.Name}';
not.ParentId = '{!Opportunity.Id}';
not.OwnerId = '{!Opportunity.OwnerId}';
var result = sforce.connection.create([not]);
if(result[0].getBoolean("success")){
window.open("/" + result[0].id + "/e");
}else{
alert('Could not create record '+result);
}

Make it as solution if it answers your question.

Rgrds,
Rabi