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
shivani GOSWAMI 8shivani GOSWAMI 8 

Write a trigger to create the number of ‘Vehicle Maintenance’ records which are equal to the number which we will enter in the ‘Number of Services’ field on the Vehicle Object

SwethaSwetha (Salesforce Developers) 
HI Shivani,
You ask seems similar to https://salesforce.stackexchange.com/questions/173243/creating-contacts-that-depend-on-an-account-field-value . The trigger code provided here should help you get started.

If this information helps, please mark the answer as best.Thank you.
Ajith Selvaraj 2Ajith Selvaraj 2
Hello Shivani,
use for loop, inside the for loop write a code to create record for vehicle maintenance. 
as like 
for(integer i=o; i< acc.noofservices; i++){
// code to create record


Thanks,
Ajith
shivani GOSWAMI 8shivani GOSWAMI 8
Thank you so much
CharuDuttCharuDutt
Hii Shivani...
my contact object have number field Records
and contacts lookup on newObject

trigger equalQuantity on Contact (After Insert, After Update) {
      List<newObject> ListToInsert = New List<newObject>();
    
    If(Trigger.IsInsert || Trigger.IsUpdate)
    {
        For(Contact con : Trigger.New)
        {
            If(con.Records__c != null)
            {
                    For(Integer I = 0; I < con.Records__c; I++)
                    {
                        newObject   lst = New newObject();
                        
                        lst.Contact__c = con.Id;
                        lst.Name       = 'Sample Name' + I;
                        
                        ListToInsert.add(lstt);
                    }
            }
                    insert ListToInsert;
        }
    }
}

If it Helps  please Mark it as a Best Answer