You need to sign in to do that
Don't have an account?

Could you please any one give a solution for my below query
Hello all
I have "contaminats" Object as a related list for Cases and the field in the objects were as follows (Name, Feed(CheckBox), Regeneration medium(CheckBox)). i need to Auto create 6 contaminats (oxygen,CO,H2,Olefins,Sulfur components,Chloride components) upon case creation as unchecked
Can any one help me with a class to create these contaminats .
I have "contaminats" Object as a related list for Cases and the field in the objects were as follows (Name, Feed(CheckBox), Regeneration medium(CheckBox)). i need to Auto create 6 contaminats (oxygen,CO,H2,Olefins,Sulfur components,Chloride components) upon case creation as unchecked
Can any one help me with a class to create these contaminats .
Why do you want to create a apex class or trigger for this. This use case can be easily achieved by using process builders. Please follow the below tutorial in helping you to use process builder for creating a child record.
https://automationchampion.com/2015/02/13/getting-started-with-process-builder-part-1-auto-create-a-record/
Hope this helps.
There two was through which you can achieve this requirement. Either write a custom Save Button on Case and create records there or you need to create a trigger on Case, which would fire when a record in inserted and would generate 6 records on a related object is Contaminants__c.
I have written a sample code for you. Don't forget to check the api names before saving your code!
Follow these steps:
Step 1: Go to Setup and in the Quick Find Box, type Classes.
Step 2: Select Apex Classes
Step 3: Paste the following class in it.
Step 4: Go to setup and in the Quick Find Box, type Case.
Step 5: Select Case Triggers.
Step 6: Paste the following Trigger in it.
Step 7: Check if it works or not :)
Can you take a moment to upvote and mark this answer as solved, if it helped you.
Cheers!
Ajinkya Deshmukh