+ Start a Discussion
ShaSha 

Trigger to updated Master field (Values) to child field (Values)

Hi Friends, 

Need quick help with a trigger for below cenario. 

Lets say i have a "Company" object and "Industry" field in it with values (CIP, FED, OTH) , Now when ever Company record is updated with Industry values child object "Job" field "Industry" should be updated catch is here if CIP is selected in child object it should show 
Consumer and Industrial Products if FED is selected in company in job it should show up Federal (Basically it should map the field)
Martijn SchwarzerMartijn Schwarzer
Hi Sha,

You can accomplish this using the Process Builder. This will give you the opportunity to update child records based on changes in the parent.

For more information, please check one of the following resources:

https://help.salesforce.com/HTViewHelpDoc?id=process_overview.htm
https://developer.salesforce.com/trailhead/en/business_process_automation/process_builder
https://www.youtube.com/watch?v=APiJg7908jk

Hope this helps!

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
ShaSha
Thank you for your reply Schwarzer, 

We have tried Process builder in first place but below error occuried and couldnt find the issue with and there are other workflows on that object. 
So moved to trigger. Please see below error and let me know if we can still use process builder. 

**************************************************************************************************
An error occurred at element myRule_1_A1 (FlowRecordUpdate).
Too many DML rows: 10001

This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange (https://success.salesforce.com/ideaSearch).
Flow Details
Flow Name: Company_indust_to_job_indust
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Company_indust_to_job_indust-1_Company__c
Current User: Abdul Syed Shareef (00540000002EcLa)
Start time: 7/25/2016 3:53 PM
Duration: 0 seconds
How the Interview Started
Abdul Syed Shareef (00540000002EcLa) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = a1t40000000FKp4AAG
myVariable_current = a1t40000000FKp4AAG
RecursiveCountVariable = 0.00
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "7/25/2016 3:53 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Industry__c} (CIP) Equals CIP
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Job__c records where:
Company__c Equals {!myVariable_current.Id} (a1t40000000FKp4AAG)
Update the records’ field values.
Industry__c = Consumer and Industrial Products
Result
Failed to update records that meet the filter criteria.

Error Occurred: Too many DML rows: 10001


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange (https://success.salesforce.com/ideaSearch).
Flow Details
Flow Name: Company_indust_to_job_indust
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Company_indust_to_job_indust-1_Company__c
Current User: Abdul Syed Shareef (00540000002EcLa)
Start time: 7/25/2016 3:53 PM
Duration: 0 seconds
How the Interview Started
Abdul Syed Shareef (00540000002EcLa) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = a1t40000000FLcXAAW
myVariable_current = a1t40000000FLcXAAW
RecursiveCountVariable = 0.00
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "7/25/2016 3:53 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Industry__c} (CIP) Equals CIP
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Job__c records where:
Company__c Equals {!myVariable_current.Id} (a1t40000000FLcXAAW)
Update the records’ field values.
Industry__c = Consumer and Industrial Products
Result
Failed to update records that meet the filter criteria.

Error Occurred: Too many DML rows: 10001


This report lists the elements that the flow interview executed. The report is a beta feature.
We welcome your feedback on IdeaExchange (https://success.salesforce.com/ideaSearch).
Flow Details
Flow Name: Company_indust_to_job_indust
Type: Workflow
Version: 1
Status: Active
Flow Interview Details
Interview Label: Company_indust_to_job_indust-1_Company__c
Current User: Abdul Syed Shareef (00540000002EcLa)
Start time: 7/25/2016 3:53 PM
Duration: 0 seconds
How the Interview Started
Abdul Syed Shareef (00540000002EcLa) started the flow interview.
Some of this flow's variables were set when the interview started.
myVariable_old = a1t40000000FLiuAAG
myVariable_current = a1t40000000FLiuAAG
RecursiveCountVariable = 0.00
ASSIGNMENT: myVariable_waitStartTimeAssignment
{!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
Result
{!myVariable_waitStartTimeVariable} = "7/25/2016 3:53 PM"
DECISION: myDecision
Executed this outcome: myRule_1
Outcome conditions: and
1. {!myVariable_current.Industry__c} (CIP) Equals CIP
Logic: All conditions must be true (AND)
RECORD UPDATE: myRule_1_A1
Find all Job__c records where:
Company__c Equals {!myVariable_current.Id} (a1t40000000FLiuAAG)
Update the records’ field values.
Industry__c = Consumer and Industrial Products
Result
Failed to update records that meet the filter criteria.

Error Occurred: Too many DML rows: 10001


 
 
 
Martijn SchwarzerMartijn Schwarzer
Hi Sha,

The problem is that there are more than 10,000 child records (which need to be updated) for the Company record. Since you can only update 10,000 records in one update statement, your flow fails.

Since you have many records to update, I would suggest kicking off a batch to update the child records. It would look like this:

Trigger calls a triggerhelper class in which you have an @future annotated method. 

The @future method will start a batch, which will update the child records.

Hope this helps!

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.