• Cal Steele
  • NEWBIE
  • 20 Points
  • Member since 2016


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies
I'm trying to set a custom Opportunity lookup field Sales Rep, which is a lookup to a custom Obj for Sales Reps, to the Opportunity Owner. Pretty new to triggers and would really appreciate any help. Here is where I'm at so far -
trigger SalesRepTrigger on Opportunity (after insert, after update) {
   
     if (trigger.isAfter) {
        if (trigger.isUpdate || trigger.isInsert) {
            
            Opportunity ops = new Opportunity();
            
            //get opporunity that triggered
            Set<ID> Ids = new set<id>();
            
            for(Opportunity o : Trigger.new){
               ids.add(o.Sales_Rep__c);
            }
            
            //get CC_Sales_Rep__c ids and store in Map
            //Map<Id, Id> RepMap = new Map<Id, Id>();
            
            Map<Id, CC_Sales_Rep__c> salesRep = new Map<id, CC_Sales_Rep__c>([Select id, OwnerId FROM CC_Sales_Rep__c
                                              Where CC_Sales_Rep__c =:ids]);
 
            //for(CC_Sales_Rep__c sr : salesRep) {
            //    RepMap.put(sr.Id, sr.OwnerId);
            //}
            
            //Get Opportunity Record Types
            Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
 
            for(Opportunity o : Trigger.new){
                //Only apply trigger to a certain record type
                if(rt_map.get(o.recordTypeID).getName().containsIgnoreCase('xxxx xxxx')){ 
                    ops.Sales_Rep__c = SalesRep.get(o.Sales_Rep__c).OwnerId;
 
                }
            }
         update ops;
        }
}
}
When checking the challenge at step 4 I recieved this error -

There was an unhandled exception. Please reference ID: TWMJUUNP. Error: ArgumentError. Message: bad argument (expected URI object or URI string)

Can anyone provide some insight on where to begin looking to fix this error?

Thanks!
I'm trying to set a custom Opportunity lookup field Sales Rep, which is a lookup to a custom Obj for Sales Reps, to the Opportunity Owner. Pretty new to triggers and would really appreciate any help. Here is where I'm at so far -
trigger SalesRepTrigger on Opportunity (after insert, after update) {
   
     if (trigger.isAfter) {
        if (trigger.isUpdate || trigger.isInsert) {
            
            Opportunity ops = new Opportunity();
            
            //get opporunity that triggered
            Set<ID> Ids = new set<id>();
            
            for(Opportunity o : Trigger.new){
               ids.add(o.Sales_Rep__c);
            }
            
            //get CC_Sales_Rep__c ids and store in Map
            //Map<Id, Id> RepMap = new Map<Id, Id>();
            
            Map<Id, CC_Sales_Rep__c> salesRep = new Map<id, CC_Sales_Rep__c>([Select id, OwnerId FROM CC_Sales_Rep__c
                                              Where CC_Sales_Rep__c =:ids]);
 
            //for(CC_Sales_Rep__c sr : salesRep) {
            //    RepMap.put(sr.Id, sr.OwnerId);
            //}
            
            //Get Opportunity Record Types
            Map<ID,Schema.RecordTypeInfo> rt_Map = Opportunity.sObjectType.getDescribe().getRecordTypeInfosById();
 
            for(Opportunity o : Trigger.new){
                //Only apply trigger to a certain record type
                if(rt_map.get(o.recordTypeID).getName().containsIgnoreCase('xxxx xxxx')){ 
                    ops.Sales_Rep__c = SalesRep.get(o.Sales_Rep__c).OwnerId;
 
                }
            }
         update ops;
        }
}
}
When checking the challenge at step 4 I recieved this error -

There was an unhandled exception. Please reference ID: TWMJUUNP. Error: ArgumentError. Message: bad argument (expected URI object or URI string)

Can anyone provide some insight on where to begin looking to fix this error?

Thanks!