You need to sign in to do that
Don't have an account?
Nils11
How to use sforce in javascript to update record ?
I have to update the lead's record type and owner name and assign new record type and current user and owner using javascript code.
I have written below code code on button but its not working.
var LeadToUpdate = new sforce.SObject("Lead");
if (LeadToUpdate.RecordTypeId=="012V0000000werfdgt") {
LeadToUpdate.Id = "{!Lead.Id}";
LeadToUpdate.RecordTypeId = "01220000000aser";
LeadToUpdate.ownerId = "{!$User.Id}";
sforce.connection.update([LeadToUpdate]);
window.location.href='/{!Lead.Id}/e?012120000012cZt';
}
I have written below code code on button but its not working.
var LeadToUpdate = new sforce.SObject("Lead");
if (LeadToUpdate.RecordTypeId=="012V0000000werfdgt") {
LeadToUpdate.Id = "{!Lead.Id}";
LeadToUpdate.RecordTypeId = "01220000000aser";
LeadToUpdate.ownerId = "{!$User.Id}";
sforce.connection.update([LeadToUpdate]);
window.location.href='/{!Lead.Id}/e?012120000012cZt';
}
I am facing below error in console.
Refused to set unsafe header "User-Agent"