Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void assignOwnerId(List<Inventory__c> invList){
- List<User> userList = new List<User>([SELECT SAP_External_Id__c, Id
- FROM User
- WHERE SAP_External_Id__c > '0' ]);
- Map<String, String> userMap = new Map<String, String>();
- for (User userLoop:userList) {
- userMap.put(userLoop.SAP_External_Id__c, userLoop.Id);
- }
- for (Inventory__c invLoop : invList) {
- invLoop.RecordTypeID = ttiProductRecId;
- if (invLoop.SAP_Account__c != null && userMap.get(invLoop.SAP_Account__c) != null) {
- invLoop.OwnerID = userMap.get(invLoop.SAP_Account__c);
- }
- }
- }
- public static void assignOwnerId(List<Inventory__c> invList){
- Set<String> sapAccountNumbers = new Set<String>();
- for (Inventory__c invLoop : invList) {
- if (invLoop.SAP_Account__c != null) {
- sapAccountNumbers.add(invLoop.SAP_Account__c);
- }
- }
- if (sapAccountNumbers.isEmpty()) {
- return;
- }
- Map<String, Id> userMap = new Map<String, Id>();
- for (User userLoop : [SELECT SAP_External_Id__c, Id
- FROM User
- WHERE SAP_External_Id__c
- IN :sapAccountNumbers]) {
- userMap.put(userLoop.TTI_SAP_Cust_No__c, userLoop.Id);
- }
- for (Inventory__c invLoop : invList) {
- invLoop.RecordTypeID = ttiProductRecId;
- if (invLoop.SAP_Account__c != null && userMap.containsKey(invLoop.SAP_Account__c)) {
- invLoop.OwnerID = userMap.get(invLoop.SAP_Account__c);
- }
- }
- }
Add Comment
Please, Sign In to add comment