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
Santro652Santro652 

Dependency objects

Hi,

 

I have to customize which i am not able to figure out requirement are as follows:

 

there are 2 custom objects A and B which are in master detail relationship:

 

When the record is created in object A the user enters a date in the field and if he does not enter the date it is considered default year 2000.

Every year the user should enter a record in B and this happens every year(Only one record is entered per year and the user knows this), if the user does not enter the record for a particular year then on the master object A, a check box should be checked.

When the user enters the particular record then the check box should get un-checked automatically.

 

i tried this via workflow but got stuck:

 

I created a rollup from object B to rollup records to object A(number of records: Count).

I wrote a formula field which gives the number of years on object A (today()-2000 or Today()-year enterd) this results in a number like =0 or 1 or as per the year calculation.

I did a comparison in the workflow saying; when the (no of years passed on object A > Rollup) then check the box on record A, but there is one more criteria which will come up which i have explained below:

 

User creates the record and enters the year(date) as 2010 on object A and saves the record, eventually when the year 2011(Jan) comes up the formula calculates and shows as '1' and now there is a difference between the two formulas and the workflow rule should trigger but this wont happen as the record should be edited and saved for the WF to trigger, i tried using somes dates and got really vary confused.

 

can anyone suggest me any idea or give me any trigger, this will be really very helpfull....

Best Answer chosen by Admin (Salesforce Developers) 
IspitaIspita

You can implement this using Apex.

Since you need this to happen silently in the backgroud it is a fit case for schedulable apex.

You can write your logic in an apex class which will do the needful logic check and ecxecute the related changes.

Then as per your business requirement you can schedule a batch job.

 

 

Hope this helps...

All Answers

IspitaIspita

You can implement this using Apex.

Since you need this to happen silently in the backgroud it is a fit case for schedulable apex.

You can write your logic in an apex class which will do the needful logic check and ecxecute the related changes.

Then as per your business requirement you can schedule a batch job.

 

 

Hope this helps...

This was selected as the best answer
Santro652Santro652

Thanks for the idea, can you share with me any samples or any link on how i can build this on the system.

IspitaIspita

Let me check and get back to you.