You need to sign in to do that
Don't have an account?
Sassberto
Passing derived classes to create()
I have created a class called WebLead which inherits sforce.Lead.
When I atttempt to pass the derived class to create() I get an error that 'WebLead was found, expected sforce.Lead'. I have tried explicitly casting WebLead to it's base class but I still get the same error.
Ideally I want to something do this:
class WebLead : Lead
{
public Save()
{
sObject[] obj = { this };
sforce.create(obj)
}
}
instead I have to do
class WebLead : Lead
{
public Save()
{
Lead myLead = new Lead();
myLead.FirstName = this.FirstName;
myLead.LastName = this.LastName;
//etc.. ad nauseum
sObject[] obj = { myLead };
sforce.create(obj)
}
}
Any ideas here?
When I atttempt to pass the derived class to create() I get an error that 'WebLead was found, expected sforce.Lead'. I have tried explicitly casting WebLead to it's base class but I still get the same error.
Ideally I want to something do this:
class WebLead : Lead
{
public Save()
{
sObject[] obj = { this };
sforce.create(obj)
}
}
instead I have to do
class WebLead : Lead
{
public Save()
{
Lead myLead = new Lead();
myLead.FirstName = this.FirstName;
myLead.LastName = this.LastName;
//etc.. ad nauseum
sObject[] obj = { myLead };
sforce.create(obj)
}
}
Any ideas here?
In your case it would look something like this:
class WebLead
{
private Lead sfLead;
public Lead SfLead {
get { return sfLead; }
put { sfLead = value; }
}
public WebLead() {
SfLead = new Lead();
}
public Save()
{
sObject[] obj = { SfLead };
sforce.create(obj)
}
}
and from outside your object...
WebLead myLead = new WebLead();
myLead.SfLead.FirstName = firstName;
...
HTH
Todd Breiholz