You need to sign in to do that
Don't have an account?
Andres Monge 9
Error Trigger insert Lookup Id into the Custom Object
I have to elements united with a lookup relation: bMerchants and Products.
If you insert one Merchant two Products will be create, I write a trigger but it throw me this error:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger InsertProducts caused an unexpected exception, contact your administrator: InsertProducts: execution of AfterInsert caused by: System.StringException: Invalid id: 24: Trigger.InsertProducts: line 29, column 1
This is the code of the Trigger:
I made everything I don't know what to do, please if any body could help me I would appreciate.
Thanks and Regards.
If you insert one Merchant two Products will be create, I write a trigger but it throw me this error:
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger InsertProducts caused an unexpected exception, contact your administrator: InsertProducts: execution of AfterInsert caused by: System.StringException: Invalid id: 24: Trigger.InsertProducts: line 29, column 1
This is the code of the Trigger:
trigger InsertProducts on Merchant__c (after insert) { List<Product__c> products= new List<Product__c>(); for(Merchant__c m: Trigger.new) { Product__c pproducts = new Product__c(); pproducts.Merchant__c = String.valueOf(m.Name); products.add(pproducts); } insert products; }
I made everything I don't know what to do, please if any body could help me I would appreciate.
Thanks and Regards.
sbb
Not sure what you are trying to do but try replacing whatever is on line 8 in your sample with this: