You need to sign in to do that
Don't have an account?
SFDC ROCK
How to write a trigger to copy few field value from one object to another object ?
How to write a trigger code with handler class to copy few field value from one object (A)to another object (B) ?
Condition :1
Object A
picklist Field : Subodh Salary =5000
picklist Field : Subodh Salary =7000
Object B
picklist Field : Subodh Total Salary :12000
Condition : 2
Object : A
picklist Field : Subodh Salary =7000
picklist Field : Rahul Salary =7000
picklist Field : Amit Salary =5000
picklist Field : Rahul Salary =7000
picklist Field : Amit Salary =5000
Object : B
picklist Field : Subodh Total Salary =7000
picklist Field : Rahul Total Salary =14000
picklist Field : Amit Total Salary =10000
Thanks
Subodh
Condition :1
Object A
picklist Field : Subodh Salary =5000
picklist Field : Subodh Salary =7000
Object B
picklist Field : Subodh Total Salary :12000
Condition : 2
Object : A
picklist Field : Subodh Salary =7000
picklist Field : Rahul Salary =7000
picklist Field : Amit Salary =5000
picklist Field : Rahul Salary =7000
picklist Field : Amit Salary =5000
Object : B
picklist Field : Subodh Total Salary =7000
picklist Field : Rahul Total Salary =14000
picklist Field : Amit Total Salary =10000
Thanks
Subodh
Generally, a trigger is written so that when ever a new record is entered or when a record is updated or deleted there could be certain operations that can be done. Can you try considering if this could be done using the OOB tools like flows or process builders so that it could be easily done.
Regards,
Anutej
We can do OOB but need to understand with trigger only.
However, in case if you would like to implement using the developer tools I think you should be able to do this use case using schedulable apex, for which the example is given in below documentation:
>>https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm
The above solution is considering the records are existing in the system and running the code at a specific interval.
In case if you want to implement to combine records and insert while inserting records, you can do something as below:
>> create a set of values of names from the incoming records and then run through the loop by adding the values and creating a list os objectb instances with name and total salaries as components and insert them after calculating the total amount.
Can you post your object relation also? It will be easy to the writer the logic. Also on which object update, you want to perform this functionality.
both are unrelated object and need to update or insert on B object.
You can write the trigger. Here is the basic example of the logic that you need. Let me know if you have any doubt.
I know it's an old thread but will this work for my below scenario? which I feel like instead of having a picklist field I have my text field.