I'm having issues getting the syntax correct on a UI formula field that references another model.

JerryJerry Member
edited September 2019 in Questions


  • edited October 2017
    Jerry, are you trying to do a MODEL_LOOKUP formula? Can you post more details?
  • JerryJerry Member
    edited November 2017
    lol you responded so quickly the community barfed when I tried to edit the question
  • JerryJerry Member
    edited November 2017
    I'm attempting to create a formula checkbox on one model that evaluates to true based on finding a row of data in a second model. I read in a question from two years ago or so that the model referenced must come before the containing model on the list. That is not an issue for me. However, my original syntax threw an error, and now with a rewrite saving and previewing the page still reports the error with the old syntax. I've checked pagebuilder and the xml prior to previewing the page and both show the most current formula even though the error shows an old one...

    Here's my error which includes the old syntax:

    1. Invalid syntax for field formula: {{$Model.ExistingNYITUtilityAccounts.data.length}}"true" AND {{$Model.ExistingNYITUtilityAccounts.data.length}}>0. [object Object]

    Here is what is saved to the page and apparently being ignored :) :

    IF({{$Model.ExistingNYITUtilityAccounts.data.length}}>1, true, false)

    I added a create default row, to the referenced model to get around the .data being undefined
  • Mike DwyerMike Dwyer Member
    edited September 2019
    Did you search the xml for any occurrence of the old syntax? Does it exist on another ui field different from the one with the corrected syntax? What about page includes to another page that still has the old code?
  • JerryJerry Member
    edited November 2017
    nope only one occurrence of that formula field

    I did get it to finally save and run on the updated formula though, not sure what changed, it just decided to work.

    The second formula in my description is doing what it should.
  • JerryJerry Member
    edited November 2017
    So, I'm having a new issue. I need to check another models first record if it exists and verify that it is a record from the Salesforce database (has the real 18 character id and not a sk-something).
    In my formula I am trying to evaluate:
    1) first that the other model has a row
       If it does I want to evaluate the id to see that it's a true salesforce record and not the default row.

    Here's what I have:
    IF({{$Model.ExistingNYITUtilityAccounts.data.length}} > 0, IF(NOT(STARTS_WITH({{$Model.ExistingNYITUtilityAccounts.data[0].Id}},"sk"), true, false),  false)

    I've also tried checking the length of the Id field to be 18, and checking the value of the Id15 field...
    The formula is returning true in error

Sign In or Register to comment.