You need to sign in to do that
Don't have an account?
aam1r
Query works in one class but not the other
I have two clases:
1. a controller class to a vf page and another as
2. a helper class accessed by multple classes.
I have a simple query running in the helper class that is failing to return any records:
"List has no rows for assignment to SObject" ?
1. a controller class to a vf page and another as
2. a helper class accessed by multple classes.
I have a simple query running in the helper class that is failing to return any records:
... public static void refreshOrder(Id orderId, Id accountId){ // Retrieve the Order Order ord = [Select Id, Name, Status From Order Where Id = :orderId]; ...The controller class that calls the above method has the following extract:
... Order order = new Order( Pricebook2Id = OrderHelper.getStandardPriceBookId(), Status = ORDER_STATUS_PENDING_PAYMENT, AccountId = acc.Id EffectiveDate = System.today(), CurrencyIsoCode=pkgCurrencyCode ); insert order; OrderHelper.refreshOrder(order.Id, acc.Id); ...Any idea why a system.debug in the helper class does show a valid Order Id being apssed but then the simple order query does not return anything, and instead throws an error:
"List has no rows for assignment to SObject" ?
1. User permissions. This was part of a process involving a Site Guest User. And although i had set up sharing rules i guess this user worjks a bit differently from a standard, rather a normal user in salesforce
2. I moved the select query from the helper class to teh controller class and then passed the field values to the helper class - and it did work. So user has access, but only in one class - not the other.
3. I then checked the class definition and yes, it was set to public with sharing. So,
4. i changed this to public without sharing
And it all worked. Of course, this means that sharing settings will not apply in this class, and that it will run on a system level. But that's fine. I'll control access to sensative info via the profile when needed.
Thanks for looking!