function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SandhyaSandhya 

i have two object building and floors,create n no of records in floors object using triggers

Ashima nidhiAshima nidhi
I am not sure what you are tring to ask, However adding some refrence for you to understand trigger. Meanwhile Visual flow /process builder could also be one of the option.

https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers/apex_triggers_intro
http://www.sfdcpoint.com/salesforce/apex-trigger-in-salesforce/

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.
ayu sharma devayu sharma dev
Hello Sandhya 

I can assume your issue is to create Floors which is a child of Building object. So to create the flow please follow:

- There must be field on Building object where you store the value for the Number of floors you require.
- Then on insertion of this field with an n numbers, this many child records of the Floor Object should be created. 

Please let me know if the above requirement is right so we can develop the code.

Regards
Ayush
SandhyaSandhya
Hi Ayush,
yes  Exactly ...that is my requirement.
Thank you for the quick reply.

 Sandhya.
ayu sharma devayu sharma dev
Hello Sandhya

One more thing, So suppose if you insert a value of 6 for floors on your building object as result 6 floor records will be created, Now if you change the value of the Number field from 6 to 8 so then there will be 8 more records will be created according to flow. So what process do you suggest in this case? 
Like
- Should we check if there are already 6 records and create 2 more.
- Create 8 new records, so total records will be 14
- Create 8 new records and delete previously create records.
- Just create records when the values insert for the first time and don't do anything if it changes in the future.

Let me know your suggestions.

Regards
Ayush Sharma 
SandhyaSandhya
Hi Ayush
no need to delete previous records 
Just create records when the values insert for the first time and don't do anything if it changes in the future.
 
SandhyaSandhya
Hi Ayush,
one more requirement,
Create 1 flat member record based owner field on flats object
(get the owner name,phone details from contact object) after insert.
fields on flatMemberobject 
1.Name: owner name
2.Mobile:phone
3.relation:self
4.Flat:flat SFDC Id
5.Contact:owner SFD Id.

Thanks in Advance,
Sandhya.