You need to sign in to do that
Don't have an account?
sush
Creation of opportunity at backend
Hi,
My requirement is to create an opportunity at backend on click of a button.
So i'm using an s-control with ajax but an error is showing up saying
'Exception thrown but not caught'.
But with the similar code i'm able to create a account...
i was using this code in between script
var opportunity=new sforce.SObject("Opportunity");
opportunity.Name = "My Opportunity";
opportunity.StageName="Prospecting";
opportunity.CloseDate="8/22/2007";
var result = sforce.connection.create([opportunity]);
var accid=result[0].Id;
alert(accid);
if (result[0].getBoolean("success")) {
alert("new account created with id " + result[0].id);
} else {
alert("failed to create account " + result[0]);
}
any help is appreciated.
thanks in advance.
I dont know much in S-Controls.
But in your statement of creating Opty we need to populate Account (Id) as necessary field.
The same would work for Account since this is Master object and no need to populate any other obj related info upon creation of new.
Am I correct.
Nazeer
try {
var result = sforce.connection.create([opportunity]);
} catch ( e) { alert(e); }
or this may work, add to your scontrol somewhere.
Code:
to my eye, that date does not look like a javascript date which the AJAX toolkit expects, see the ajax documentation.
opportunity.CloseDate=new Date("8/22/2007")
That should fix the issue, as the date will be properly translated when it's in a Date object representation.~ sfdcfox ~