SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT Id, ProcessInstance.TargetObjectId
  2.        FROM ProcessInstanceWorkitem
  3. USING SCOPE Mine_And_My_Groups
  4.       WHERE ProcessInstance.Status = 'Pending'
  5.              AND ProcessInstance.ProcessDefinition.TableEnumOrId IN ('Account', 'Contact')
  6.      
  7. System.UnexpectedException: Illegal filter on ProcessInstanceWorkitem
  8.      
  9. @IsTest
  10. static void testAsAdmin() {
  11.  
  12.     User u = getTestUser([SELECT Id FROM Profile WHERE Name = 'System Administrator'][0].Id);
  13.  
  14.     System.runAs(u) {
  15.         //SUCCEEDS
  16.         List<ProcessInstanceWorkitem> workitems = [
  17.                 SELECT Id, ProcessInstance.TargetObjectId
  18.                 FROM ProcessInstanceWorkitem
  19.                 USING SCOPE Mine_And_My_Groups
  20.                 WHERE ProcessInstance.Status = 'Pending'
  21.                 AND ProcessInstance.ProcessDefinition.TableEnumOrId IN ('Account', 'Contact')
  22.         ];
  23.     }
  24. }
  25.  
  26. @IsTest
  27. static void testAsStandardUser() {
  28.  
  29.     User u = getTestUser([SELECT Id FROM Profile WHERE Name = 'Standard User'][0].Id);
  30.  
  31.     System.runAs(u) {
  32.  
  33.         //FAILS
  34.         List<ProcessInstanceWorkitem> workitems = [
  35.                 SELECT Id, ProcessInstance.TargetObjectId
  36.                 FROM ProcessInstanceWorkitem
  37.                 USING SCOPE Mine_And_My_Groups
  38.                 WHERE ProcessInstance.Status = 'Pending'
  39.                 AND ProcessInstance.ProcessDefinition.TableEnumOrId IN ('Account', 'Contact')
  40.         ];
  41.     }
  42. }
  43.  
  44. static User getTestUser(Id profileId) {
  45.     return new User(
  46.             Alias = 'test',
  47.             Email = 'exampletestuser@example.com',
  48.             EmailEncodingKey = 'UTF-8',
  49.             FirstName = 'Testing',
  50.             LastName = 'Testing',
  51.             LanguageLocaleKey = 'en_US',
  52.             TimeZoneSidKey = 'America/Los_Angeles',
  53.             LocaleSidKey = 'en_US',
  54.             UserName = 'exampletestuser@example.com',
  55.             ProfileId = profileId
  56.     );
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top