formula field syntax error

I’m getting this error in runtime:

Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘scheduledInitialAppointments’,‘TotalRecords’,‘grpCategories’,{{grpCategories}}). SyntaxError: missing ) after argument list

However, as you can see from the formula reproduced in the error message, there is just one open and one close parenthesis.

This would be amusing, if I didn’t need it to work. Even so, still slightly amusing.

Errors:

3. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}})) *100. SyntaxError: missing ) after argument list
4. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}})) *100. SyntaxError: Unexpected token )

Single quotes, double quotes.
double mustaches, triple mustaches.

Still getting the same error on the model_lookup function:

1. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘scheduledInitialAppointments’,‘TotalRecords’,‘grpCategories’,{{grpCategories}}). SyntaxError: missing ) after argument list2. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘scheduledInitialAppointments’,‘TotalRecords’,‘grpCategories’,{{grpCategories}}). SyntaxError: missing ) after argument list
3. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}}) *100. SyntaxError: missing ) after argument list
4. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}}) *100. SyntaxError: missing ) after argument list
5. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}}) *100. SyntaxError: missing ) after argument list
6. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(‘AVRonIntake’,‘TotalRecords’,‘grpCategories’,{{{grpCategories}}}) *100. SyntaxError: missing ) after argument list
7. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(“completedInitialAppointments”,“TotalRecords”,“grpCategories”,Initial {{CaseType}} Appointment) *100. SyntaxError: missing ) after argument list
8. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(“completedInitialAppointments”,“TotalRecords”,“grpCategories”,Initial {{CaseType}} Appointment) *100. SyntaxError: missing ) after argument list
9. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(“completedInitialAppointments”,“TotalRecords”,“grpCategories”,Initial {{CaseType}} Appointment) *100. SyntaxError: missing ) after argument list
10. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(“ReturnAppointmentsScheduled”,“TotalRecords”,“grpCategories”,{{grpCategories}}) *100. SyntaxError: missing ) after argument list
11. Invalid syntax for field formula: {{TotalRecords}} / MODEL_LOOKUP(“ReturnAppointmentsScheduled”,“TotalRecords”,“grpCategories”,{{grpCategories}}) *100. SyntaxError: missing ) after argument list

The Model lookup function only seems to work when I pass a static value for the last argument… it will not process merge syntax.

Both of the following work:

{{TotalRecords}} / MODEL_LOOKUP(“completedInitialAppointments”,“TotalRecords”,“grpCategories”,“Initial Pregnancy Appointment”) *100

{{TotalRecords}} / MODEL_LOOKUP(‘numberOfSchedulingLeads’,‘TotalRecords’,‘grpCategories’,null) *100

Is total records another formula field?  You alerted us to that issue last week. 

No, TotalRecords is a COUNT(Id).

I’m getting this same error when trying to merge in a field from an external data source.