SHARE
TWEET

Untitled

a guest Jul 17th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Profile profile = [Select Id from Profile where name = 'ORT Direct Sales User'];
  2.     User nonAdminUser = new User( ProfileId = profile.Id, Username = System.now().millisecond() + 'test2@test.com.dev',UserRoleId = '00E1G000000IX0IUAW',
  3.                                 Alias = 'batman', Email='bruce.wayne@wayneenterprises.com', EmailEncodingKey='UTF-8',Firstname='Bruce',
  4.                                 Lastname='Wayne',LanguageLocaleKey='en_US',LocaleSidKey='en_US',TimeZoneSidKey='America/Chicago' );
  5.     System.runAs(new User( Id = UserInfo.getUserId() ))
  6.     {
  7.         Database.insert(nonAdminUser);
  8.     }
  9.  
  10.     Account acc = TestUtility.createAccount( TestUtility.default_account_rt, false );
  11.     acc.Name = 'sfdcpoint';
  12.     acc.Account_Status__c = 'Active';
  13.     insert acc;
  14.  
  15.     System.runAs(nonAdminUser)
  16.     {
  17.         Contact cont = TestUtility.createContact( TestUtility.default_contact_rt , acc, false );
  18.         cont.MailingStreet = 'Test Street' ;
  19.         cont.MailingCity = 'Minneapolis';
  20.         cont.MailingState = 'MN';
  21.         cont.MailingPostalCode = '55347';
  22.         cont.MailingCountry = 'United States' ;
  23.         insert cont;
  24.  
  25.         BusinessUnits__c bu = new BusinessUnits__c( Contact__c = cont.Id, LineOfBusiness__c = 'Central Title Division' );
  26.         bu.Sales_Rep__r.UserRole.DeveloperName = 'Central_Title_Agency1';
  27.         insert bu ;
  28.  
  29.         try
  30.         {
  31.             BusinessUnits__c bu1 = new BusinessUnits__c( Contact__c = cont.Id, LineOfBusiness__c = 'Central Title Division' );
  32.             bu1.Sales_Rep__r.UserRole.DeveloperName= 'Central_Title_Agency1';
  33.             insert bu1 ;  
  34.         }
  35.         catch(DmlException de )
  36.         {
  37.  
  38.         }
  39.     }
  40.  
  41. }
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