You need to sign in to do that
Don't have an account?
Meena25
FATAL_ERROR System.QueryException: List has no rows for assignment issue to SObject
ownerUser = [Select Id, UserRoleId from user where UserRoleId IN :lstUser AND Id = :opp.OwnerId];
This is causing me the exception, what is wrong with this?
If it a test class insert the data to meet the above SOQL condition ..
If its a class you can able to handle like below
AuraHandledException e = new AuraHandledException('The application is already with ABC team');
e.setMessage('The application is already with ABC team');
system.debug(e);
throw e;
public class classname {
@AuraEnabled
public static Opportunity updateoppOwner(String oppId) {
List<User> ownerUser;
Opportunity opp = [Select Name,OwnerId From Opportunity where Id = :oppId];
List<UserRole> lstUser = [Select Id,Name from userRole where Name LIKE 'ABC%'];
If (lstUser != null && lstUser.size()>0){
ownerUser = [Select Id, UserRoleId from user where UserRoleId IN :lstUser AND Id = :opp.OwnerId];
//system.debug('ownerUser:' +ownerUser);
}
If (ownerUser != null){
AuraHandledException e = new AuraHandledException('The application is already with team');
e.setMessage('The application is already with team');
system.debug(e);
throw new AuraHandledException(e.getMessage());
//throw new AuraHandledException('The application is already with team');
}
else
{
User usr = [Select Id, Name from User where Name = 'ABC' limit 1];
opp.OwnerId = usr.Id;
system.debug('Owner record has been updated');
update opp;
}
return opp;
}
}