You need to sign in to do that
Don't have an account?
Alejandro Garcia Lopez
Hello, help whit this : System.QueryException: List has no rows for assignment to SObject
Hello, i have a problem with this trigger, i need to update a field from account (Pendientes_Realizados__c) but the query doesn't return something (c.Oferta__r.gerente_operativo__c) is an id from account that query returns the id in workbench but nothing in the trigger
trigger gerente on Documento__c (after update) { for (Documento__c c:Trigger.new) { Account l=[select Pendientes_Realizados__c from Account where id=:c.Oferta__r.gerente_operativo__c]; l.Pendientes_Realizados__c=10; update l; } }
All Answers
The exception is because of you are not getting any record in your SOQL query..
which meet the where criteria so it's give error.
in workbench it will return id coz its checking the full object. in trigger its checking for the current record of the trigger. so there is no id for the currenct record.
Documento__c c:Trigger.new ---- means you are retriving record based on current record instatce( c) c.Oferta__r.gerente_operativo__c.
to avoid this error always do null check before retrie the records.
kinldy use below modified code.
hope this will work for you.
make it solved if its works for you
Thanks
karthik