• SteveT2121
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

i figured this should be pretty simple. I have a custom object called ONSITE_PRODUCT__c

onsite_product__c has a lookup field called product__c which has a lookup relationship to the salesforce products object. 

 

ive created a new picklist field called New_products__c which also has a list of the same products as the product__c lookup field. I want a user to select a product from the New_products__c picklist and have that same product value saved as the product lookup field value.

 

heres my trigger

 

trigger UpdateOnsiteProduct on Onsite_Product__c (before insert,before update) {
    { 
        for (Onsite_Product__c a : Trigger.new) 
        { 
            a.Product__c = a.New_Products__c;
        }
    }
}

 

 

and this is the error i keep receiving

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdateOnsiteProduct caused an unexpected exception, contact your administrator: UpdateOnsiteProduct: data changed by trigger for field Product: id value of incorrect type: XYZ PRODUCT

 

Thanks.

i figured this should be pretty simple. I have a custom object called ONSITE_PRODUCT__c

onsite_product__c has a lookup field called product__c which has a lookup relationship to the salesforce products object. 

 

ive created a new picklist field called New_products__c which also has a list of the same products as the product__c lookup field. I want a user to select a product from the New_products__c picklist and have that same product value saved as the product lookup field value.

 

heres my trigger

 

trigger UpdateOnsiteProduct on Onsite_Product__c (before insert,before update) {
    { 
        for (Onsite_Product__c a : Trigger.new) 
        { 
            a.Product__c = a.New_Products__c;
        }
    }
}

 

 

and this is the error i keep receiving

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger UpdateOnsiteProduct caused an unexpected exception, contact your administrator: UpdateOnsiteProduct: data changed by trigger for field Product: id value of incorrect type: XYZ PRODUCT

 

Thanks.