Activity Forums Salesforce® Discussions How does system change event not work for change in object type attribute in Salesforce lightning?

  • Deepak

    Member
    December 12, 2019 at 5:14 pm

    component.set('v.acc.Name', 'Name from 3!');
    To:

    var acc = component.get('v.acc');
    acc.Name = 'Name from 3!';
    component.set('v.acc', acc);
    And everything will work.

    Here is why you are seeing this behavior, and why the workaround is working:

    The rule to remember: all changes are propagated down, but only propagated up when they affect the root of the attribute.
    About the workaround: because component.get('v.acc') is returning a pointer to the object (this is JavaScript after all), we are not not copying the data, and it is not less efficient than calling component.get('v.acc.Name'). Sure it is more verbose, but not less efficient!

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos