Skip to main content

Hi All,

Have a page that contains numerous models, and a range of components linked to these models spread down the page. Components for a specific model are dispersed through the page, not all grouped together.

Problem is, on a save error I get standard messages replicated up the page against each of the multiple components linked to the affected model. Looks horrific.  Thus, Im trying to intercept all errors and aggregate them against one component at top of page.

in my save snippet, I am trying to push each error to target UI component using initiatorId param but getting nowhere.  Any suggestions on how this is used?  Relevant sections of my code below:


var myPage = skuid.$('#FormTitle');<br>var myeditor = myPage.data('object').editor;<br>.<br>.<br>.<br>models.save({ callback : checkResult }); // assume I save the models<br>function checkResult(result){<br>if(!result.totalsuccess) {<br> &nbsp; &nbsp; myeditor.handleMessages(result.messages,{ &nbsp;initiatorId : "FormTitle" } );<br> &nbsp; &nbsp;return false;<br>}

}

If you can’t figure out the solution you are pursuing, you could instead create separate models for each component. It isn’t the cleanest or most convenient option, but it may save you a few hours of trying to figure out how to do what you are trying to do.


Thanks Raymond. I appreciate your response. Unfortunately with 11 models already that’d expand DML queries out to say 30 for the page, affecting efficiency and performance significantly. There must be a simple way to define where to put error messages surely ?


On certain components (like field editors) in the component settings there is a “Display” tab. On the display tab, there is an errors tab. It allows you to determine if errors are shown inline and whether you only want them to show upon hover.


Yep good suggestion. I did try that and so now errors appear on fields AND against all elements in the page that is bound to the model that has validation errors - nasty UI experience!  I keep hoping that there is a way to consolidate all errors from all models onto one page element. Seems page hacks are the next step which seems counter productive.


This works Carl 🙂


var params = argumentsn0],&nbsp; &nbsp; $ = skuid&#46;$;<br />&#47;&#47; Clear our list of messages<br />var myPage = skuid&#46;$('#FormTitle');<br />var stepEditor = myPage&#46;data('object')&#46;editor;<br />stepEditor&#46;clearMessages();<br />var models =  <br />&nbsp; &nbsp; skuid&#46;model&#46;getModel("DetailsForm"),<br />&nbsp; &nbsp; skuid&#46;model&#46;getModel("SForm"),<br />&nbsp; &nbsp; skuid&#46;model&#46;getModel("Qualificaiton")<br />];<br />var messages =  ];<br />$&#46;each(models,function(i,model){<br />&nbsp; &nbsp;$&#46;each(model&#46;registeredLists,function(j,list){<br />&nbsp; &nbsp; &nbsp; &nbsp;var listMessages = list&#46;validateRequiredFields();<br />&nbsp; &nbsp; &nbsp; &nbsp;if(listMessages &amp;&amp; listMessages&#46;length) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$&#46;each(listMessages,function(){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; messages&#46;push(this);&nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});<br />&nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp;});<br />});<br /><br />var DetailsModel = skuid&#46;model&#46;getModel('DetailsForm');<br />var DetailsForm = DetailsModel&#46;getFirstRow();<br />if(DetailsForm&#46;CountryOfBirth__c == 'Australia' &amp;&amp; (DetailsForm&#46;StateOfBirth__c ==='' || DetailsForm&#46;CityOfBirth__c==='' )){<br />&nbsp; &nbsp; messages&#46;push({<br />&nbsp; &nbsp; &nbsp; &nbsp; message: 'When Country of birth is Australia, State/Territory of birth and Suburb/City of birth are required',<br />&nbsp; &nbsp; &nbsp; &nbsp; severity: 'ERROR'<br />&nbsp; &nbsp; });&nbsp;<br />}<br />&#47;&#47; If we have warning messages, do NOT proceed<br />if (messages&#46;length) {<br />&nbsp; &nbsp; &#47;&#47; Have our step's editor handle the messages<br />&nbsp; &nbsp; stepEditor&#46;handleMessages(messages);<br />&nbsp; &nbsp; return false;<br />}

Thanks for sharing Hassantha…