function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jaw999jaw999 

Select Count UserRecordAccess work around?

I'd like to get the workaround equivalent to the posted code, but it does not seem possible to run a count on the UserRecordAccess object?


if ([select count() from UserAccessRecord
            where UserId = :UserInfo.getUserId() and AccountId = :sc.getId()] > 0) {
        return true;
    }


SeAlVaSeAlVa
What about...

if([
  SELECT
    MaxAccessLevel,
    RecordId
  FROM
    UserRecordAccess
  WHERE
    UserId = :UserInfo.getUserId() AND
    RecordId = :sc.getId()
  LIMIT 1
  ].size() > 0)
{
    return true;
}


jaw999jaw999
Hmm. 
Error: Compile Error: Non-void method might not return a value or might have statement after a return statement. at line
jaw999jaw999
added 
return true;
}
    else {
    return false;
    }