Issue with If statement in FormulaMap

Hi All,

Having issue with following code in a button. Spent hours and I’ve narrowed it down to a specific line “Person.Contains(TimeEmployees)”

If I remove that portion, code runs. I dont understand why that line would cause the code to break.

For reference, “TimeEmployees” field is from Controls → Multiple Select Button.

RunActions(

    [Timesheet Record UnSubmitted]
    .formulamap(
      Switchif(
        And(
          Date >=[Timesheet Start Date],
          Date <= [Timesheet End Date],
          Person.Contains(TimeEmployees)
        ),
        [Timesheet Submitted]
          .AddRow(
            [Timesheet Submitted].Date,
            Date,
            [Timesheet Submitted].Person,
            Person,
            [Timesheet Submitted].[Project/Customer],
            [Project/Customer],
            [Timesheet Submitted].[Service Items],
            [Service Items],
            [Timesheet Submitted].Hr,
            Hr
          )
          
      )
    ),

  DeleteRows([Timesheet Record UnSubmitted].Filter(Person.Contains(TimeEmployees)))

)

Hey @Dan_Park ,
welcome to the community!

Is there any chance to share the doc? There could be a couple of reasons including data format of either person or TimeEmployees why it does not work. Hard to debug without seeing the doc.

First thing I’d try is using TimeEmployees.Contains(Person) instead. It sounds like Time Employees is a list of employees while Person is just one person. AFAIK the formula is =Haystack.Contains(Needle).

1 Like

Thanks for the tip! @Daniel_Stieber

Tried it and still having the same issue.

Below is link to the doc. I’ve not shared docs before. let me know I am doing it correctly. Thanks in advance!

Hi @Dan_Park ,

the only change I had to do was to add a fallback action to the switchif part (even though it’s officially optional), _noop() already does the trick. Can you reproduce this fix?

2 Likes

Thank you!! @M_Schneider

That solved the it completely!

2 Likes