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
Danica Alexis LlantosDanica Alexis Llantos 

Hi, I need a help with apex that will add Installment Date (Date Field) to the number of Terms (number field)

For ex: Installement Date is 4/01/2023 and number of terms is 30 days the custom field should print out 5/1/2023. If number of terms is 0 it should print out the next installment date.

Terms is under Master-Detail(Invoice) while Installment Date is under Installment (child object)
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Danica,

Can you confirm Installation is child and Invoice is Master object also on which object were Installmentdate, Terms and new field to add those date is present ?

Thanks
 
Danica Alexis LlantosDanica Alexis Llantos
Hi Sai,


Thank you for your response, yes - Installment is child object and Invoice is a Master Object, Installment Date is under Installment Object and Terms and New custom field (Date Field ) is under Invoice. I was suppose to create a formula field usig this formula IF( fw1__Terms__c  = 0,  fw1__Installment_Date__c ,
    DATE(YEAR(fw1__Installment_Date__c), MONTH(fw1__Installment_Date__c), DAY(fw1__Installment_Date__c) + fw1__Terms__c)
)

But snce the Installment Date is under child object I was getting an error as Parent records can't look down to the child records.
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Danica,

As installemnt is child object and Invoice can have multiple installment record so which record should it consider to add the terms to installation Date?

Thanks,
 
Danica Alexis LlantosDanica Alexis Llantos
User-added image


In this sample record the higlighted part should capture the Installment plus terms, if terms is 0 get the next Installment Date which is 6/1/2023