You need to sign in to do that
Don't have an account?
Deja Bond
Sobject creation
Hi, I need help converting this method into an sobject, so it can accept two different types of objects
So currently the method is returning a lead activity record, but I want it to return a candidate record if the object is a contact, so I was thinking to add another condition to return something like return new LightningActivity(candidateRecord) if this isn't a RH_Lead__c object
public static LightningActivity fetchTestActivity(RH_Lead__c leadRecord) {
if(leadRecord == null){
system.debug('got a null');
return fetchTestActivity();
}
return new LightningActivity(leadRecord);
}
So currently the method is returning a lead activity record, but I want it to return a candidate record if the object is a contact, so I was thinking to add another condition to return something like return new LightningActivity(candidateRecord) if this isn't a RH_Lead__c object
public static LightningActivity fetchTestActivity(RH_Lead__c leadRecord) {
if(leadRecord == null){
system.debug('got a null');
return fetchTestActivity();
}
return new LightningActivity(leadRecord);
}
So do you think this would work?
Do I need to return(candidateRecord ) somewhere ?
public static LightningActivity fetchTestActivity(sobject leadRecord) {
if(leadRecord == null && leadRecord.getSObjectType=='RH_Lead__c')
{
system.debug('got a null');
return fetchTestActivity();
}
if(candidateRecord == null && candidateRecord getSObjectType=='Contact')
{
system.debug('got a null');
return fetchTestActivity();
}
else{
return new LightningActivity(leadRecord);
}
}
"Constructor not defined: [LightningActivity].<Constructor>(SObject)"
"Variable does not exist: getSObjectType"
@AuraEnabled
public static LightningActivity fetchTestActivity(sobject leadRecord, sobject candidateRecord) {
if(leadRecord == null && leadRecord.getSObjectType=='RH_Lead__c')
{
system.debug('got a null');
return fetchTestActivity();
}
if(candidateRecord == null && candidateRecord.getSObjectType=='Contact')
{
system.debug('got a null');
return fetchTestActivity();
}
else{
return new LightningActivity(leadRecord);
}
}
Am I missing something?