Uncaught TypeError: cannot read property 'Id' of undefined when changing a picklist that triggers snippet

  • 1
  • Problem
  • Updated 2 years ago
  • Solved
I have a picklist that lets the sales reps choose an opportunity scope (field name Objective__c).  Based on the selection, different fields display, and default values are set.

The snippet that sets these default values works correctly the first time you select any option.

But once you select Default (simplest, fewest fields), and then switch back to any other option, the ui does not update, and there is an error in the console:

Uncaught TypeError: Cannot read property 'Id' of undefined

Here's the skuid function that fails:
function Y(a) {        var b, d, e = a[0], f = {};
        return a.length < 2 ? !1 : (c(a[1]) ? (d = {},
        d[a[1]] = a[2],
        b = a[3]) : (d = a[1],
        b = a[2]),
        f[e.Id] = d,
        this.updates = f,
        void (this.options = b))
    }

Specifically the error points to:
f[e.Id] = d,

None of the fields that get defaults are rendered until after the objective is selected. 
Photo of Jared Jones

Jared Jones

  • 2,214 Points 2k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Jared Jones

Jared Jones

  • 2,214 Points 2k badge 2x thumb
Figured it out.  When "Default" was selected, the snippet was cancelling the other models.