You need to sign in to do that
Don't have an account?

Trigger to update lookup field after insert not working
Hi,
I have a custom object Product_Serial__c which has a lookup field to another object Product_inventory__c.
The product_inventory__c has a lookup to Product.
The product serial record also has a lookup to product
Now when a user creates a new Product Serial record ,
i created a trigger on the Product serial that updates the product value from the product_inventory which the user enters to create a record.
But this update is not happening.Please help.
Trigger updprod on Product_serial__c(after insert)
{
Set<Id> ids = trigger.newmap.keySet();
List<Product_serial__c> pser=[select product_inventory__c,product__c,Product_Inventory__r.Product__r.Id from product_serial__c where id IN :ids];
For(Product_serial__c psers:pser)
{
psers.product__c=psers.Product_Inventory__r.Product__r.Id;
update psers;
}
}
its really works......
Do you get an error, or does the data not update as you would expect?
Have you tried adding debug statements to check that the field that you retrieve from the related Product_Inventory__c is correctly populated etc?
Hi Bob,
There is no error,but the value is not updating..
I can't see anything obviously wrong with your trigger. Try adding some debug and turning on debug logs via the monitoring menu. Something like: