You need to sign in to do that
Don't have an account?
Sneha Kathavate
Missing return statement required return type: Boolean error
Hi All,
I am relatively new to Apex coding. I have written a class which is giving the error "Missing return statement required return type: Boolean". Could you plz help me resolve this .
public class CC_JobBoardApp_checkstatus {
@AuraEnabled
public static Boolean checkstatus()
{
Set<Id> jobid = new Set<Id>() ;
for(TR1__Job_Board_Application__c jba :
[SELECT TR1__Status__c,TR1__Job__c,Job_Id__c
from TR1__Job_Board_Application__c
where Id in :JobId
LIMIT 1])
if(jba.TR1__Status__c=='Rejected')
{
return true;
}
else
{
return false;
}
}
}
The class checks if the status of the job application is rejected. If it is rejected, then returns true else returns false.
I am relatively new to Apex coding. I have written a class which is giving the error "Missing return statement required return type: Boolean". Could you plz help me resolve this .
public class CC_JobBoardApp_checkstatus {
@AuraEnabled
public static Boolean checkstatus()
{
Set<Id> jobid = new Set<Id>() ;
for(TR1__Job_Board_Application__c jba :
[SELECT TR1__Status__c,TR1__Job__c,Job_Id__c
from TR1__Job_Board_Application__c
where Id in :JobId
LIMIT 1])
if(jba.TR1__Status__c=='Rejected')
{
return true;
}
else
{
return false;
}
}
}
The class checks if the status of the job application is rejected. If it is rejected, then returns true else returns false.
You can do it in the following way. Hope this works for you.
public class CC_JobBoardApp_checkstatus {
@AuraEnabled
public static Boolean checkstatus()
{
public boolean isRejected = false;
Set<Id> jobid = new Set<Id>() ;
for(TR1__Job_Board_Application__c jba :
[SELECT TR1__Status__c,TR1__Job__c,Job_Id__c
from TR1__Job_Board_Application__c
where Id in :JobId
LIMIT 1])
if(jba.TR1__Status__c=='Rejected')
{
isRejected = true;
}
return isRejected;
}
}
Thank You
Ajay Dubedi
All Answers
Try to declare a varaible with boolean as type and then return the value in your if else condition.
Refer below sample code
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards
Sandhya
You can do it in the following way. Hope this works for you.
public class CC_JobBoardApp_checkstatus {
@AuraEnabled
public static Boolean checkstatus()
{
public boolean isRejected = false;
Set<Id> jobid = new Set<Id>() ;
for(TR1__Job_Board_Application__c jba :
[SELECT TR1__Status__c,TR1__Job__c,Job_Id__c
from TR1__Job_Board_Application__c
where Id in :JobId
LIMIT 1])
if(jba.TR1__Status__c=='Rejected')
{
isRejected = true;
}
return isRejected;
}
}
Thank You
Ajay Dubedi
Hope this code may help you:
Regards
Nandigam