0

We have a CASE() function on a Field Update for which the Workflow criteria is Custom_Field1__c NOT EQUAL TO null then Update another Custom_Field2__c using below formula:

CASE(Custom_Field3__c,
     "4004","6835",
     "4001","6830",
     "4002","6831",
     "")

This is not working as expected!

Instead of Setting Custom_Field2__c = 6835 when Custom_Field3__c == 4004, System is setting the value for Custom_Field2__c = blank and Setting the same field = 6835 when Custom_Field3__c == 4001. And when i change Custom_Field3__c = 4002, i am seeing Custom_Field2__c = 6830.

I couldn't find anything in debug logs too! Did anyone experience this kind of behavior before?

enter image description here

4
  • My concern is that it seems you have filtered out logic in an attempt to hide some potentially proprietary information and the formula you have here is not a true representation of what you're trying to do.
    – gNerb
    Nov 29, 2018 at 14:51
  • I just set up a test in my org using your exact formula/criteria and it works fine, if you can provide a more accurate representation of your formula I will take another look, as it stands, other than the missing comma, there are no issues with what you are describing.
    – gNerb
    Nov 29, 2018 at 15:02
  • @gNerb I've tried the same thing in a dev org and it was working fine but i am not able to understand what's going on wrong here.
    – SunnyG
    Nov 29, 2018 at 15:23
  • @gNerb If you look at the screenshot i added to the post. Magic code is getting updated by a field update which is evaluated whenever Type value is changed. And based on Magic Code, below two fields Agency Object and Index Code are updated. This is the actual formula: CASE(Magic_Code__c, "4044","6835", "4001","N/A", "4004","1001", "4006","1002", "4008","1003", "4010","1004", "4050","6380", "4052","6831", "") In the same screenshot, value you see for Agency object is different than what it is in the CASE function. Prior value of Magic Code was 4052.
    – SunnyG
    Nov 29, 2018 at 15:29

1 Answer 1

0

The only thing I can see is that you are missing a comma (,) after your second last line before "")

It should be:

CASE(Custom_Field3__c,
 "4004","6835",
 "4001","6830",
 "4002","6831",
 "")
7
  • Would that not cause a syntax error? Even if SFDC is smart enough to add the strings together the number of params should be incorrect.
    – gNerb
    Nov 29, 2018 at 14:51
  • Case works as follows: Case(Field_To_Parse, value1, result1, value2, result2, else)
    – Joe Hayes
    Nov 29, 2018 at 14:54
  • Right, so CASE(Custom_Field3__c, "4004","6835", "4001","6830", "4002","6831""") would translate to Cast(field_to_parse, value1, result1, value2, result2,value3,result3) with no default. That means that if you do not get an error for missing the comma you will get an error for incorrect number of parameters.
    – gNerb
    Nov 29, 2018 at 14:56
  • I just confirmed that I am correct, the error for missing the comma is Error: Syntax error. Missing ')' which means you answer doesn't actually address the issue. The missing comma is most likely a translation error, read my comment on OP's post.
    – gNerb
    Nov 29, 2018 at 14:58
  • I'd probably go for this and include a blank default at the end if the value isnt in there: CASE(field_to_parse, value1, result1, value2, result2, value3, result3, "")
    – Joe Hayes
    Nov 29, 2018 at 14:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .