Display error message using a SKUID snippet, editor undefined

  • 2
  • Problem
  • Updated 3 years ago
  • Solved
I want to display an error message with as below with a skuid snippet,


var $ = skuid.$;
var pageTitle = $('#PersonalDetailsForm');
var editor = pageTitle.data('object').editor;
var PersonalDetailsFormModel = skuid.model.getModel('PersonalDetailsForm');
var PersonalDetailsForm = PersonalDetailsFormModel.getFirstRow();

if (PersonalDetailsForm.Asic_CountryOfBirth__c === 'Australia') {

    editor.handleMessages(
        [{
            message: 'Error message xyz',
            severity: 'ERROR'
        }]
    );

    return false;
}


the "var editor = pageTitle.data('object').editor;" sections gives an error message saying that
"Uncaught TypeError: Cannot read property 'editor' of undefined"

The wired thing here is that the same code snippet worked for some other pages in my system without an error.

Why am I getting this error in my second implementation, I have noticed that there is a model with the same name as the pageTitle "PersonalDetailsForm",
Could this be an issue?

Appreciate your help
thanks.
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Are you sure that the ID defined for the page title component on your page is exactly  "PersonalDetailsForm "   Case sensitivity is key here. 
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Rob, Thanks for the help, it was a silly mistake of mine, I've been referring to the "Page name" instead of Page Title -> Advance -> Unique Id.
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Whew! Glad it was an easy fix.