Uncaught TypeError: Cannot read property 'hasChanged' of undefined

Blank screen on page load, with this error. Any ideas?


Iā€™m not a master of javascript debugging but the last line jumps out to me. Click on it and take another screenshot of the source code surrounding line 82.

You asked for it :wink:

Here are the contents of line 82. Looks like the XML for the entire page.

skuid.component.factory('#skuid-page-a0fF00000092AN2IAM-component-1','{{Name}}STD ProcessInteractionPatientCaseInteractionsTableRelatedPersonSTDSTDTestPatientCaseInteractionRelatedPersonPatientSTDCategoryPurposeTypePermission to Say &quot;CompassCare&quot;Other RelationshipInsert List of STD Tests here for RN to review with Patient.Anal Sex Given (M)Anal Sex Received (M/F)Vaginal Sex Given (M)Vaginal Sex Received (F)Oral Sex Given (M/F)Oral Sex Received (M/F)Other STD&lt;h1&gt;STD History&lt;/h1&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;strong&gt;Results&lt;/strong&gt;&lt;strong&gt;Reported to Patient&lt;/strong&gt;&lt;strong&gt;Reported to Health Dept.&lt;/strong&gt;&lt;strong&gt;Treatment&lt;/strong&gt;&lt;h1&gt;Physicians&lt;/h1&gt;Description{{Description1__c}} {{Description2__c}}Address&lt;h1&gt;Insurance&lt;/h1&gt;Description&lt;h1&gt;Additional Referrals&lt;/h1&gt;Description{{Description1__c}} {{Description2__c}}AddressOther Religious Background&lt;h1&gt;MotherCare&lt;/h1&gt;Address<custom name="scriptJTex

Looking again, itā€™s not all the XML, just everything inside .

Hence the name ā€œskuid.component.factoryā€ I presume.

heheheā€¦ a screenshot. Not copy paste.

:wink: While weā€™re at it, hereā€™s line 28 of skuid__SkuidJS, which is throwing the error:

W=new a.model.Condition,W.operator="gte",W.field=Y,W.inactive=!0,W.name=Z,W.encloseValueInQuotes=!1,X=new a.model.Condition,X.operator="lte",X.field=Y,X.inactive=!0,X.name=$,X.encloseValueInQuotes=!1,v.model.addCondition(W),v.model.addCondition(X)}if(d=v.model.getField(W.field),e=v.model.getField(X.field),!d||!e)return!1;var _,ab,bb=d.displaytype,cb=e.displaytype;W.inactive?_="":"DATETIME"===bb?(i=q(W.value),_=r(i)):(i=p(W.value),_=W.value),X.inactive?ab="":"DATETIME"===cb?(j=q(X.value),j.setDate(j.getDate()-1),ab=r(j)):(j=p(X.value),ab=X.value);var db=function(){eb.datepicker("getDate")||fb.datepicker("getDate")?pb.show():pb.hide()},eb=A.DATE.edit({value:_,onChange:db}).addClass("sk-timefilter-input"),fb=A.DATE.edit({value:ab,onChange:db}).addClass("sk-timefilter-input");v.element.addClass("nx-actionselect nx-conditiontoken");var gb,hb,ib=l("
"),jb=l("
").addClass("nx-actionselect-text").append(ib),kb=l("
").addClass("nx-actionselect-arrow").append(l("
")),lb=l("
").addClass("nx-actionselect-dropdown sk-timefilter-body").hide(),mb=l("
").text(t("start_date")).addClass("sk-timefilter-label"),nb=l("
").text(t("end_date")).addClass("sk-timefilter-label"),ob=l("
"),pb=l("
").addClass("sk-timefilter-clearfilter-button").text("Clear Filter");pb.click(function(){eb.datepicker("setDate",null),fb.datepicker("setDate",null),db()}),B?(hb=l("
").text(t("done")).addClass("sk-timefilter-button"),ob.append(hb)):(gb=l("
").text(t("cancel")).addClass("sk-timefilter-button-grey"),hb=l("
").text(t("apply")).addClass("sk-timefilter-button"),ob.append(hb,gb)),v.updateDisplayValue=function(b,c){var d,e=o.makeFormattedDateFromJS,f=a.label.merge;return d=b&&c?e(b)+" - "+e(c):b&&!c?f(t("after_this"),e(b)):!b&&c?f(t("before_this"),e(c)):t("all_time"),ib.text(d),eb.datepicker("setDate",b),fb.datepicker("setDate",c),db(),v},v.updateDisplayValue(i,j),gb&&gb.click(function(){lb.hide("fast")}),v.activateFilter=function(){var a,b,c=eb.datepicker("getDate"),d=fb.datepicker("getDate");if(c&&(a=r(c)),d&&(b=r(d)),a?("DATETIME"===bb&&(a=s(p(a))),v.model.setCondition(W,a,v.affectCookies)):v.model.deactivateCondition(W,v.affectCookies),b){if("DATETIME"===cb){var e=p(b);e.setDate(e.getDate()-0+1),b=s(e)}v.model.setCondition(X,b,v.affectCookies)}else v.model.deactivateCondition(X,v.affectCookies);v.setOriginalValue({start:c,end:d})},hb.click(function(){var a=eb.datepicker("getDate"),b=fb.datepicker("getDate");B?v.list.showFilterActions():(v.activateFilter(),v.executeFilter()),v.updateDisplayValue(a,b),lb.hide("fast")}),lb.append(mb,eb,nb,fb,pb,ob),v.element.addClass("nx-actionselect-haslabel").append(jb,kb,lb),jb.add(kb).click(function(){lb.is(":visible")?lb.toggle("fast"):(lb.css("min-width",Math.max(v.element.width(),180)+"px"),lb.show("fast"))})}"toggle"===x||"auto"!==C&&"manual"!==C||(h=l("
").addClass("nx-actionselect-label"),"auto"===C?"daterange"===x?f=d.label:c&&(f=c.label):"manual"===C&&(f=k.attr("label"),f&&(f=n.mergeAsTextInContext(f,{model:v.model}))),f&&(h.text(f),v.element.addClass("nx-actionselect-haslabel").prepend(h))),v.selectedItem||v.isMultiselect||(c&&v.isReferenceFilter?v.selectedItem=v.element.actionAutocomplete("getSelectedItem"):"daterange"===x?v.setOriginalValue({start:i,end:j}):v.selectedItem=v.element.actionSelect("getSelectedItem"))}function h(a){a=a||{};var b=this,e=a.grandparent,f=a.parent,g=a.model,h=a.element;b.model=g,e.css({overflow:"hidden","overflow-x":"hidden","overflow-y":"hidden"}),f.css({position:"relative","padding-left":"0px","padding-right":"0px",height:"100%"}),b.element=h.addClass("nx-queue").data("object",b).appendTo(f);var i=a.title?n.mergeAsText("model",a.title,{createFields:!0,registerFields:!1},g):"";b.header=l("
").addClass("nx-queue-header").attr({"aria-controls":h.prop("id")}),b.headerInner=l("
").addClass("nx-queue-header-inner").appendTo(b.header),b.titleBar=l("
").addClass("nx-queue-titlebar").appendTo(b.headerInner),(a.showSearchBox===!0||a.filtersXML&&a.filtersXML.children&&a.filtersXML.children().length>0)&&(b.titleIcon=l("
").addClass("ui-icon ui-icon-gear nx-queue-titleicon").on("click",function(){b.settingsBar.toggle(),b.element.css("border-top",b.header.height()+2+"px solid white")}).appendTo(b.titleBar)),b.titleText=l("
").text(i).addClass("nx-queue-titletext").appendTo(b.titleBar),b.settingsBar=l("
").addClass("nx-queue-settings").hide().appendTo(b.headerInner),f.append(b.element,b.header),b.editor=new c(b.element,{showSaveCancel:!1,buttonPosition:"block"});var j={};j.render=function(c){c.element.addClass("nx-queue-item");var d=l("
").addClass("nx-queue-item-inner").appendTo(c.element);a.tagRenderer&&a.tagRenderer(b.model,b.list,c,d)},b.views={standard:j},b.list=new d(b.editor,b.model,{views:b.views,listFilters:a.filtersXML,conditions:a.editorConditions,showSearchBox:a.showSearchBox,useSOSLSearch:a.useSOSLSearch,SOSLFields:a.SOSLFields,searchMethod:a.searchMethod||"server",searchConditionName:a.searchConditionName,tokenizeSearch:"undefined"!=typeof a.tokenizeSearch?a.tokenizeSearch:!0,searchPlaceholderText:a.searchPlaceholderText,delayFilterExecution:a.delayFilterExecution}),b.model.registerList(b.list),b.list.render(),b.list.attach();var k=this.list.editor.header;k.detach().appendTo(b.settingsBar),b.element.on("click.skuid",".nx-queue-item",function(b){var c=l(this).data("object");a.tagClickAction&&a.tagClickAction(c),b.stopPropagation()})}function i(a,b){b||(b={});var c=b.mode||"edit",d=l("
").addClass("nx-editor-contents nx-basicfieldeditor-section-body");return l.each(a,function(a,e){var f=l("
").addClass("nx-basicfieldeditor-item"),g=l("
").addClass("nx-basicfieldeditor-item-label").text(e.metadata.label).appendTo(f);e.mode=c,e.editable=e.metadata.editable,e.editor=b.editor,e.wrapperElement=f,e.labelElement=g,e.render(),f.append(e.element),d.append(f)}),d}function j(a,b,c){a&&(a.css("opacity",1).show(),b.text(c))}function k(a,b,c,d){a&&(b.text(c),0===d?a.hide():a.animate({opacity:"0"},d||500,function(){a.hide()}))}var l=a.$,m=a.ui={},n=a.utils,o=a.time,p=o.parseSFDate,q=o.parseSFDateTime,r=o.getSFDate,s=o.getSFDateTime,t=a.label.read,u=n.encodeHTML,v=n.decodeHTML,w=window.sforce&&sforce.one?sforce.one:!1,x=window.sforce&&sforce.console&&sforce.console.isInConsole()?sforce.console:!1;c.prototype.id=function(){return this._GUID},c.prototype.registerModel=function(a){var b=this,c=!a.hasChanged;b.models.push(a),a.registerEditor(b),b.options.showSaveCancel&&!b.submitbuttons&&(b.savebutton=l("
").addClass("sk-button-save").text(t("save")).skooButton({icon:"sk-icon-save",disabled:c}),b.cancelbutton=l("
").addClass("nx-button-secondary sk-button-cancel").text(t("cancel")).skooButton({icon:"sk-icon-cancel",disabled:c}),b.savebutton.on("click.skuid",function(){l(this).removeClass("ui-state-hover"),b.submitbuttons&&b.submitbuttons.filter(".ui-button").button("disable"),b.save()}),b.cancelbutton.on("click.skuid",function(){l(this).removeClass("ui-state-hover"),b.submitbuttons&&b.submitbuttons.filter(".ui-button").button("disable"),b.cancel()}),b.submitbuttons=b.savebutton.add(b.cancelbutton),b.submitwrapper.append(b.savebutton,b.cancelbutton))},c.prototype.registerList=function(a){this.lists.push(a),this.registerModel(a.model)},c.prototype.unregister=function(){var a=this;return a.lists&&a.lists.length&&l.each(a.lists,function(){this.unregister&&this.unregister()}),a.models&&a.models.length&&l.each(a.models,function(){this.unregisterEditor(a)}),a},c.prototype.hasModelWithChanges=function(){var a=this,b=!1;return l.each(a.models,function(){return this.hasChanged?(b=!0,!0):void 0}),b},c.prototype.handleChange=function(){var a=this;a.submitbuttons&&a.submitbuttons.filter(".ui-button").button("enable"),a.lists.length&&l.each(a.lists,function(a,b){b.disableFiltersAndSearch()})},c.prototype.clearMessages=function(){this.messages&&this.messages.empty()},c.prototype.handleMessages=function(a,b){var c=this;return c.messages?b&&b.initiatorId&&c._GUID!==b.initiatorId?!1:void l.each(a,function(a,b){var d="nx-message";"ERROR"===b.severity||"FATAL"===b.severity?d="nx-error":"WARNING"===b.severity&&(d="nx-warning");var e;try{e=c.messages.children("."+d).filter(":contains('"+n.escapeSelector(b.message)+"')")}catch(f){}if(e&&e.length)if(e.data("dupcount")){var g=parseInt(e.data("dupcount"),10)+1;e.children(".nx-dupcounter").text(g),e.data("dupcount",g)}else e.data("dupcount",2),e.prepend('
2
');else{var h=l("
").addClass(d);h.append("DUPLICATE_VALUE"===b.status?b.message:l("
").text(v(b.message))),h.on("click.skuid",function(){l(this).remove()}),c.messages.append(h)}}):!1},c.prototype.handleCancel=function(){var a=this,b=!1,c={};l.each(a.models,function(a,d){d.hasChanged&&(b=!0,c[d.id]=!0)}),b===!1&&(a.clearMessages(),a.submitbuttons&&a.submitbuttons.filter(".ui-button").button("disable")),a.lists.length&&l.each(a.lists,function(a,b){!b.model||b.model.id in c||b.enableFiltersAndSearch()})},c.prototype.handleSave=function(a){var b=!1,c={},d=this;l.each(d.models,function(a,d){d.hasChanged&&(b=!0,c[d.id]=!0)}),a?d.hideStatus(t("saved")):d.hideStatus("",0),d.clearMessages(),a&&!b&&d.submitbuttons&&d.submitbuttons.filter(".ui-button").button("disable"),!a&&b&&d.submitbuttons&&d.submitbuttons.filter(".ui-button").button("enable"),d.lists.length&&l.each(d.lists,function(a,b){!b.model||b.model.id in c||b.enableFiltersAndSearch()})},c.prototype.cancel=function(){a.model.cancel(this.models,{initiatorId:this._GUID})},c.prototype.save=function(b){b=b||{};var c="rollbackOnAnyError";!(c in b)&&c in this.options&&(b[c]=this.options[c]),this.setStatus(t("saving")),b.initiatorId=this._GUID,a.model.save(this.models,b)},c.prototype.setStatus=function(b){a.ui.setStatus(this.status,this.statustext,b)},c.prototype.hideStatus=function(b,c){a.ui.hideStatus(this.status,this.statustext,b,c)},c.prototype._createConditionsFromXml=function(a,b){return b&&a?b.createConditionsFromXml(a):void 0},d.prototype.id=function(){return this._GUID},d.prototype.unregister=function(){var b=this;return b.model&&b.model.unregisterList(b),b.renderedItems&&l.each(b.renderedItems,function(){this.unregister&&this.unregister()}),b.options.responsive&&a.responsive.unregisterGrid(b.id()),b},d.prototype.getSelectedItems=function(){var a=[];return l.each(this.renderedItems,function(b,c){c.selected&&a.push(c)}),a},d.prototype.unSelectAll=function(){l.each(this.renderedItems,function(a,b){b.selected&&(b.selected=!1)})},d.prototype.addSearchField=function(a,b){var c=this;if(a){var d,e=c.model.getField(a.id),f=e.displaytype;f in m.searchableDisplayTypes&&e.filterable&&(e.id in c.searchFieldsMap||(d=l.extend({},e),b&&(d.searchOperator=b),c.searchFields.push(d),c.searchFieldsMap[e.id]=d))}},d.prototype.addSearchSubField=function(a,b){var c=this;if("object"==typeof b&&(b=b.id),a&&b){var d=c.model.getField(b,a),e=d.displaytype;if(e in m.searchableDisplayTypes&&d.filterable){var f=c.searchSubFieldsMap[a],g=c.searchSubFields[a];f||(f=c.searchSubFieldsMap[a]={},g=c.searchSubFields[a]=[]),d.id in f||(f[d.id]=1,g.push(d))}}},d.prototype.addRequiredField=function(a){this.requiredFields[a.id]=a},d.prototype.removeRequiredField=function(a){delete this.requiredFields[a.id]},d.prototype.validateRequiredFields=function(){var a=this,b=[],c=a.model,d=a.requiredFields;return l.each(c.changes,function(e,f){if(!("__deleted"in f)){var g={severity:"ERROR",status:"REQUIRED_FIELD_MISSING",fields:[]},h=c.getRowById(e),i="",j=!1;h&&h.Id in a.renderedItems&&l.each(d,function(a,b){var d=c.getFieldValue(h,a,!0),e=(""===d||null===d)&&"BOOLEAN"!==b.displaytype;e&&(i&&(i+=", "),i+="["+b.label+"]",g.fields.push(b.label),j=!0)}),j&&(g.message=t("required_fields_have_no_value")+" "+i,b.push(g))}}),b},d.prototype.getView=function(a){return a||(a=this.currentView),this.views[a]},d.prototype.setUp=function(a){this.callViewOperation("setUp",a)},d.prototype.beforeRender=function(a){this.callViewOperation("beforeRender",a)},d.prototype.renderComplete=function(a){this.callViewOperation("renderComplete",a)},d.prototype.tearDown=function(a){this.callViewOperation("tearDown",a)},d.prototype.callViewOperation=function(a,b){b||(b=this.getView()),b&&a&&a in b&&b[a](this)},d.prototype.getAllRows=function(){var a,b,c=this;return c.conditions?a=n.filterRowsByConditions(c.model.data,c.conditions):(a=[],c.model.data&&c.model.data.length&&l.each(c.model.data,function(b,c){a.push(c)})),c.customFilter&&c.customFilterValue&&(b=[],l.each(a,function(){c.customFilter(c.customFilterValue,this)&&b.push(this)}),a=b),a},d.prototype.render=function(b){b=b||{};var c,d,e=this,f=e.options,g=[],h=b.previousView||!1,i=h&&h!==e.currentView,j=e.getView(),k=!e.element||b.doNotCache||j.alwaysFullRender,m=b.changedRows;j.alwaysFullRender&&(b.doNotCache=!0),i&&(h=e.getView(h),h&&e.tearDown(h)),b.resetPagination&&(e.currentPage=0),d=e.getAllRows();var n=d.length,o=e.currentPageSize,p=0,q=n;if(e.footer&&(e.footerleft.empty(),e.footercenter.empty(),e.footerright.empty()),(!e.element||i)&&(e.element&&e.element.remove(),e.element=l("<"+(j.nodeType||"div")+">").addClass("nx-list"),c=e.contents=l("<"+(j.contentsNodeType||"div")+">").addClass("nx-list-contents").appendTo(e.element),f.responsive&&a.responsive.registerGrid(e.id(),c.addClass("sm-grid").data({precision:f.gridPrecision||4,minwidth:f.gridMinWidth||300,layoutmode:"rigid"})),e.setUp(j)),o&&"all"!=o&&n>o){e.currentPage<0&&(e.currentPage=0);var r=Math.ceil(n/o);e.currentPage>r-1&&(e.currentPage=r-1),p=o*e.currentPage,q=o*(e.currentPage-0+1),e.currentPage==r-1&&(q=n),d=d.slice(p,q);var s=l("
").addClass("nx-buttonset"),u=l("
").addClass("first").text(t("first")).button(),v=l("
").addClass("prev").text(t("previous")).button(),w=l("
").addClass("next").text(t("next")).button(),x=l("
").addClass("last").text(t("last")).button(),y=e.currentPage2?e.currentPage+2:4;s.append(u,v);for(var A=y;z>=A;A++)if(A>=0&&r>A){var B=l("
").text(A-0+1).attr("data-pn",A).button();A===e.currentPage&&B.addClass("nx-button-selected"),s.append(B)}s.append(w,x).buttonset(),s.children().filter('[data-pn="'+e.currentPage+'"]').button("disable"),0===e.currentPage?(u.button("disable"),v.button("disable")):e.currentPage==r-1&&(x.button("disable"),w.button("disable")),this.footerright.append(s),s.on("click",".ui-button",function(){var a=l(this);a.is(".first")?e.goToPage(0):a.is(".prev")?e.prevPage():a.is(".next")?e.nextPage():e.goToPage(a.is(".last")?r-1:parseInt(a.data("pn"),10))})}if(o&&"all"!=o&&n){var C=[5,10,25,50];-1==C.indexOf(e.options.pageSize)&&C.push(e.options.pageSize),-1==C.indexOf(e.currentPageSize)&&C.push(e.currentPageSize);var D=function(a,b){return a-b};C.sort(D);for(var E=l("

EDIT: I bolded the 4 occurances of hasChanged in the above. Perhaps that actually useful to someone?

Matt gets the award for sending the most codeā€¦

I usually get this error when I have not defined an sObject for a model. Ā Maybe you started to set up a model and then stopped to do somthing else and forgot about it? Ā Happens to me all the time.Ā 

My two cents. Donā€™t think it has anything to do with hasChanged. Thatā€™s skuid js and I donā€™t itā€™s their js that has a bug. Maybe, but I doubt it.

Does your page models point to any custom objects/fields. If not, Iā€™ll take a look at the page if you want copy the page XML to here.

Rob, all the models have sObjects.

Pat, Thanksā€¦ itā€™s entirely custom objects.

Iā€™m guessing it has something to do with how the models are set up, but I havenā€™t been able to diagnose.

Whatā€™s the last change you made? Assuming this worked before that.

I made some changes early this week to which model would get the url parameter, and reordered the models. But everything seems to be set up the way it should with the models & conditions.

Iā€™d make a clone and start to remove one model at a time to see when the page starts to work again.

Wellā€¦ that was strange.

I realized that just before I noticed the error, I had added a field editor with a single field.

I removed that field editor, and voila! I worked.

I then added a field editor and the same field back again, and it still works!

So, I remain confused, but I have a working page. :slight_smile:

How many lines of xml is the page?

1592

Hi Matt,

We consider any javascript error that comes from our code a problem with Skuid. Ā Even if something is horribly wrong with your XML, Skuid Javascript should give you a nice error. Ā One really cool feature I found recently in Chrome Dev Tools is the ā€œPretty Printā€ button on the ā€œSourcesā€ tab.



In the future, if you want to get closer to where the error is happening, click that button and it will turn one line of minified nastiness into lots of lines of slightly more understandable nastiness. Ā I absolutely love that feature though.

Yup. I have no idea.

Sweet. Thanks, Ben!

WOW!!! That button is awesome!!!