You need to sign in to do that
Don't have an account?
cribis
Compile Error: Expression cannot be assigned at line -1 column -1
I am trying to write a trigger that will check the opportunity ownerid and returns fields from the owner's user record. but I am recieving the following error.
Compile Error: Expression cannot be assigned at line -1 column -1
Here is my code:
trigger OpportunityOwnersAddress on Opportunity (before insert, before update) { Set<Id> UserIds = new Set<Id>(); for (Opportunity oppo: Trigger.new){ System.debug('**** 0 userids id : '+oppo.ownerid); UserIds.add(oppo.Id); System.debug('**** 1 oppo id : '+oppo.id); } Map<Id, User> entries = new Map<Id, User>( [select Id, Street from User where id in :UserIds limit 1]); for(Opportunity unity: Trigger.new) { opportunity.Opp_Owner_Address__c = user.street; } }
How can this be solved?
Thank you,
Its saying that the list 'us' is empty, i.e. your query against User returned no rows, which will be a result of you adding the opportunity Id (i.e. oppo.id) to the UserIds set, rather than oppo.ownerId
All Answers
the last loop is wrong, you have unity as the loop variable in the for, but opportunity as the variable inside the loop. Also you reference user.street, and user isn't defined.
Thank you for your help. A follow-up question:
I have changed the code to:
And I am getting a new error:
The problem is still with the final line
From what I can figure out, is that the trigger is not finding a record to process. I am intending to set this up to pull from any user record in the system.
What am I missing?
Thanks,
Its saying that the list 'us' is empty, i.e. your query against User returned no rows, which will be a result of you adding the opportunity Id (i.e. oppo.id) to the UserIds set, rather than oppo.ownerId
This solved the errors. Thank you