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
vaishnavi Sonavane 1vaishnavi Sonavane 1 

How to create record for every week of the Month.

Hello

I have 2 custom object with master detail relationship.
Monthly_Plan__c(Master) and Weekly-Plan__c(Child).

1.Monthly_Plan__c Object have Start_Date__c field
2.Weekly-Plan__c Object have Start_Date__c field and End_Date__c field 

For example : If I select Start_Date__c field of Monthly_Plan__c Object as 1/07/2018(1/july/2018) then my trigger should create 5 child records for the Weekly-Plan__c Object because July month have 5 weeks.

for example
My first record should be for first week of the month 
i.e 
   Start_Date__c should be 1/07/2018
&  End_Date__c Should be 7/07/2018

Similarly,
My second record should be for Second week of the month 
i.e 
   Start_Date__c should be 8/07/2018
​&  End_Date__c Should be 14/07/2018

and so on.

 
IGNACIO SARMIENTO LOSADA1IGNACIO SARMIENTO LOSADA1
Hi Vaishnavi,

You have to code your solution. I would recommend you to use a schedule job + a batch process. Check these trailheads:

https://trailhead.salesforce.com/en/modules/asynchronous_apex/units/async_apex_scheduled
https://trailhead.salesforce.com/en/modules/asynchronous_apex/units/async_apex_batch

Let my know if this helps you.
Thanks