In the following example, where it says "xxxxxx", is it possible to write to a field on ACCOUNT (parent) within this code, somehow referencing it from the Opportunity that is currently being touched? I know I have AccountID to work with in the Opp itself, but the only time I'm touching Account is when I create the KeySet of (bulkified) Account(s) being dealt with - I can't use acctLoop since of course it's a closed FOR by that point.
Map<String, Account> acctMap = new Map<String, Account>();
for (Account acctLoop : System.Trigger.new)
{
acctMap.put(acctLoop.Id, acctLoop);
}
for ( Opportunity oppLoop1 : [ SELECT Id FROM Opportunity WHERE AccountId IN :acctMap.KeySet() ] )
{
oppLoop1.Name = 'testing xxx'; // testing..
update(oppLoop1);
--- xxxxxx ---
}
I was thinking of POSSIBLY trying to open the FOR loop to encompass the Opp Loop, and clear the acctMap at tne end of the main FOR loop (overkill, but then I'd have access to acctLoop I believe). Would that be a hack way to get it done? Is there a better way? Can I do something akin to "(opp.accountid).FieldName = 'xxx'"?
ADDED: The other idea would be to omit the Map and just wrap the Opp FOR inside the Acct FOR, and reference "AccountId IN acctLoop.Id"... if that makes sense.