Search code examples
salesforceformula

Formula in update record on salesforce flow not working


I have created the below formula but every time I debug it, it always updates the record with the false value even if the criteria are met

IF(

 AND(

    OR(

       {!$Record.RecordType.DeveloperName} = "Hotel Opportunity",

        {!$Record.RecordType.DeveloperName} = "Hotel Opportunity - Approved"

     ),

     OR(
       ISPICKVAL({!Loop_through_Copy_Requirement_Records.Status__c}, "New Copy      Loaded"),
       ISPICKVAL({!Loop_through_Copy_Requirement_Records.Status__c}, "Copy Received"),
       ISPICKVAL({!Loop_through_Copy_Requirement_Records.Status__c}, "Ready to Go"),
       ISPICKVAL({!Loop_through_Copy_Requirement_Records.Status__c}, "Copy Already Held")
     ),
     OR( ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "BE"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "CH"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "DE"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "DK"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "IT"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "NL"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "NO"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "SE"),
         ISPICKVAL({!Loop_through_Copy_Requirement_Records.Territory__c}, "UK")

 )

  ),

 "Copy Already Held",

"Copy Needed"

)

Tried debug but think something is wrong on the formula


Solution

  • In no specific order...

    Try with proper value for RecordType.DeveloperName. DeveloperName (a.k.a. API Name) will have underscores. Either check exactly what you have in the record type or edit the formula to use RecordType.Name

    You could try simplifying by commenting out parts of the formula like leave just the recordtype-ish part in, check if it enters the "true" part. Uncomment next part and see again?

    Flow's debug mode should list the values of the fields used in the expression evaluation, that should help nailing down what doesn't match?

    P.S. This technically is config, not code. You'll get better and quicker help with admin problems at dedicated https://salesforce.stackexchange.com/