Dependent record Due Date Calculation

VIKASM535239375
Kilo Sage

When we create Multiple records from Parent records using Custom Table the Date on Parent records should change the Dates on Dependent table records which are created using Custom Table Template.

1 REPLY 1

Amitoj Wadhera
Kilo Sage

Hello @VIKASM535239375 ,

 

Here's a step-by-step approach to achieve the desired functionality:

  1. Determine the Relationship: Make sure that you have the appropriate relationship defined between the parent and dependent records. Typically, there will be a reference field on the dependent table that links it to the parent record.

  2. Create a Business Rule: Create a business rule on the custom table (dependent table). This business rule should run when a record is inserted or updated. Here’s how you set up a business rule:

    • Go to the dependent table in the table list.
    • In the "Business Rules" related list, click on "New" to create a new business rule.
    • Provide a name for the business rule.
    • Choose the type of operation (insert or update) that should trigger the business rule.
    • Set the "When" field to before or after depending on when you want the synchronization to happen.
    • In the Script field, write the code that will synchronize the dates.
  3. Write the Business Rule Script: In the business rule, write a script that does the following:

    • Identify the parent record: Use the reference field on the dependent table to find the parent record.
    • Update the dependent record: If a change occurs in the parent record’s date field, find the dependent records and update their date fields accordingly.

    Here’s script:

 

(function executeRule(current, previous /*null when insert*/) {
    var parentGR = new GlideRecord('parent_table'); // Replace 'parent_table' with the actual parent table
    if (current.parent && parentGR.get(current.parent)) {
        current.dependent_date_field = parentGR.parent_date_field;
    }
})(current, previous);
​

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Regards,

Amitoj