You need to sign in to do that
Don't have an account?
Apex Trigger needed to assign task to owner of parent object
Definitely not new to the cloud here but just dipping my toe into the pool of Apex.
I understand my limitations with workflow and realize that I cannot assign a task "across objects". I have a custom object "Order" that gets integrated into Salesforce as a read only object from our legacy order system. I would like to assign a task to the owner of the account to which the order is attached. This task will be due 14 days after the Created Date of the Order.
Workflow can remedy this IF I was to assign the task to the owner of the Order record. This will not work because the "owner" of the Order object is the "integration admin" or license used in the integration from our legacy system. The Account is referenced in the Order record.
Sorry for the remedial request, but if anyone on this board can get me started, I would appreciate the help. Thanks!
* I neglected to include that these tasks should only be assigned when the Order is a Sample (Order_Type__c = "Sample").
You will need a trigger to get you through this.
I'm guessing that you shouldnt have updates on your order object so a trigger which works on insert should suffice.
Use the below code as a starting point and add detail as required. Let me know if you have any problems.
Thank you for your response. What should I replace f1__c, f2__c with?
f1__c and f2__c are some dummy field API names. replace them with the API names of actual fields u need to use for the task assignment. You can then use these field values for assigning task attributes.