0

In the Formula part of a Field Update Workflow I was able to update a custom field in my Activity Assignment record with the email address of the Owner from the parent Sales Opportunity, using:

K__ResourcedActivity__r.K__DeliveryElement__r.K__DeliveryGroup__r.K__SalesOpportunity__r.Owner:User.Email 

However, when I try to run DML to do the same to all my existing records:

K__ActivityAssignment__c aa = [SELECT MY_Sales_Opportunity_Owner__c FROM K__ActivityAssignment__c WHERE MY_Sales_Opportunity_Owner__c ='fred.bloggs@mydomain.com'];
aa.MY_Sales_Opportunity_Owner__c = K__ResourcedActivity__r.K__DeliveryElement__r.K__DeliveryGroup__r.K__SalesOpportunity__r.Owner:User.Email ;
update aa;

I get:

Expecting a semi-colon, found ':'

Any ideas?

1

The second line should owner.email instead of owner:user.email.

aa.MY_Sales_Opportunity_Owner__c = K__ResourcedActivity__r.K__DeliveryElement__r.K__DeliveryGroup__r.K__SalesOpportunity__r.Owner.email ;
8
  • That gives: Variable does not exist: K__ResourcedActivity__r.K__DeliveryElement__r.K__DeliveryGroup__r.K__SalesOpportunity__r.Owner.Email – finisterre Mar 11 '14 at 14:59
  • is MY_Sales_Opportunity_Owner__c a email field or user lookup? – Prady Mar 11 '14 at 15:37
  • My destination custom field is type 'email'. The original 'Owner' field in the parent record is Lookup(User,Queue) – finisterre Mar 11 '14 at 15:55
  • Where are you getting this field K__ResourcedActivity__r.K__DeliveryElement__r.K__DeliveryGroup__r.K__SalesOpportunity__r from ? Are you querying for it? – Prady Mar 12 '14 at 3:21
  • Ah, good question. I probably need to query for it in order to set something else equal to it? The only DML I was running was as per my snippet. – finisterre Mar 12 '14 at 8:57
0

In the second line what you mean by Owner:User at the end? There is the problem I guess. In addition to that I'm confused whether it's a good idea to have this much of deep relation in a DML

3
  • I'm not entirely sure! I'm a bit of a novice, and this was how somebody told me to do it! It seems to get the email address of the Owner of the Sales Opportunity, such that I can write it into my custom field in my child record (Activity Assignment). – finisterre Mar 11 '14 at 15:02
  • Well it does when used to do a Field Update Workflow anyway. – finisterre Mar 11 '14 at 15:09
  • I remember now. I built the full path using the INSERT FIELD widget in the Workflow Editor. – finisterre Mar 11 '14 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.