0

I would like to ask you how can we formulate the code below in advanced formula on salesforce .

the goal is the field Deadline date ( formula date type) update automatically if we fill Payment condition (Picklist type ) and Invoice sent date ( date type )

on payment condition picklist values are :

  • 30 jours après la date de réception facture
  • 75 jours après la date de réception facture

first of all we need to test if Invoice sent date field is not null :

if( Invoice_sent_Date__c <> NULL ) { if(BEGINS(Payment_condition__c ,30))

 {
    Deadline date = Invoice_sent_Date__c +30 ;
 }
 else  if(BEGINS(Payment_condition__c ,45))

 {
      Deadline date = Invoice_sent_Date__c +45 ;
 }
 else 

 {
      Deadline date = Invoice_sent_Date__c +75 ;
 }

}

for the payement condition I try to use CASE instead of If but there is an error :

CASE( TEXT( Payment_condition__c ),"30 jours après la date de réception facture",(Invoice_sent_Date__c +30) , "75 jours après la date de réception facture", (Invoice_sent_Date__c +75))

I really appreciate your solution

thanks in advance

0

This sounds like set of Workflow Rules/Field Update is your best bet. You'll be able to test all of the field criteria using the standard WFR Rule Criteria and Filter Logic. You'll need to change Deadline Date to not be a formula, but then a workflow of something like:

Rule 1. Deadline Date equals Blank

Rule 2. Payment Condition not equal

Rule 3. Invoice Date Sent not equal to Blank

And a field update using a formula of Invoice Date + (X) depending on your Rule 2 criteria.

Set the WFR to evaluate only "created, and any time it’s edited to subsequently meet criteria" and you should be good to go.

1
  • I'd also like to add, that by using a formula instead of a WFR will cause you some issues (unless its the expected result) that any changes to the Date or Picklist will constantly re-calculate the formula, rather than set a 'point in time' update like a WFR can. – HomerJ Oct 30 '15 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.