Skip to main content

Hi, 

 

I have always had issues with the formula fields syntax's , while I don't come from developer background it becomes difficult to debug such issues when I'm sure of the logic. Is there any open source tool where I can check for the indentation , syntax .. for the Salesforce formula fields which can help me debug. Thanks in advance.

7 件のコメント
  1. 2021年3月10日 18:16

    It helps to think about the formula structure before writing it, which comes after understanding the argument requirements for each function.

    Record type :

    Occupied , Renewals

    Conditions for: SLA Met

    IF

    a. ) All of the below are NOT blank:

    Days_to_Audit

    Days_to_Raw_Data

    Days_to_Audit_Report

    AND

    b.) All of the above added together are less than or equal to 57 THEN this should be SLA Met

    Conditions for: On Track to Meet SLA

    IF

    a.) At least one, or more of the below are blank:

    Days_to_Audit

    Days_to_Raw_Data

    Days_to_Audit_Report

    AND b.) None of these individually, OR added together are greater than 57 THEN it should be On Track to Meet SLA

    Conditions for: SLA NOT Met

    IF

    a.) Any one of the below individually OR added together are greater than 57

    Days_to_Audit

    Days_to_Raw_Data

    Days_to_Audit_Report

    THEN it should be SLA NOT Met

    Since you have 3 desired outcomes of "SLA Met," "On Track to Meet SLA," and "SLA NOT Met" you should expect to use IF functions:

    IF(something, "SLA Met",

    IF(something else, "On Track to Meet SLA", "SLA NOT Met")

    That "something" is literally plug and play. You can use the formula above and type the "something" logic elsewhere to not confuse yourself too much.

    So now that you have the basic logic, let's work on the "something" which again, was:

    Record type :

    Occupied , Renewals

    Conditions for: SLA Met

    IF

    a. ) All of the below are NOT blank:

    Days_to_Audit

    Days_to_Raw_Data

    Days_to_Audit_Report

    AND

    b.) All of the above added together are less than or equal to 57 THEN this should be SLA Met

    When you see "all of the above," you probably want to use AND

    When you see either record types, you probably want to use OR

    These are all the conditions you want to fill out line by line (without the ORs and ANDs yet:

    RecordType.DeveloperName = "Occupied"

    RecordType.DeveloperName = "Renewals"

    NOT(ISBLANK(Days_to_Audit))

    NOT(ISBLANK(Days_to_Raw_Data))

    NOT(ISBLANK(Days_to_Audit_Report))

    Days_to_Audit + Days_to_Raw_Data + Days_to_Audit_Report <= 57

    Now if you understand how OR and AND work:

    AND(

    condition 1,

    condition 2,

    condition n

    )

    OR(

    condition 1,

    condition 2,

    condition n

    )

    You literally just plug those line conditions into your formula:

    Either record type, so it's:

    OR(

    RecordType.DeveloperName = "Occupied"

    RecordType.DeveloperName = "Renewals"

    )

    All the other conditions must meet so it's:

    AND(

    OR(

    RecordType.DeveloperName = "Occupied"

    RecordType.DeveloperName = "Renewals"

    ),

    NOT(ISBLANK(Days_to_Audit)),

    NOT(ISBLANK(Days_to_Raw_Data)),

    NOT(ISBLANK(Days_to_Audit_Report)),

    Days_to_Audit + Days_to_Raw_Data + Days_to_Audit_Report <= 57

    )

    We have now created your first "something" which you can just paste over the "something" placeholder from the IF formula above.

    IF(

    AND(

    OR(

    RecordType.DeveloperName = "Occupied"

    RecordType.DeveloperName = "Renewals"

    ),

    NOT(ISBLANK(Days_to_Audit)),

    NOT(ISBLANK(Days_to_Raw_Data)),

    NOT(ISBLANK(Days_to_Audit_Report)),

    Days_to_Audit + Days_to_Raw_Data + Days_to_Audit_Report <= 57

    ), "SLA Met",

    IF(something else, "On Track to Meet SLA", "SLA NOT Met")

    Now we just need to replace the "something else" with its appropriate logic.

    If you can get in this mindset of thinking of the structure and building out the higher level logic, then working on the specifics, that can avoid a lot of confusion.

    If you start to see from this example that formulas are modular, that should help you dramatically.

0/9000