This is based on the finding by Tanzir at https://community.skuid.com/t/dynamic-model-createrowifnonefound-prevents-load?topic-repl…
When a page that does not contain any declarative models loads, the model service adapters are not being loaded. This results in any dynamic models failing to initialize because the following line of code returns undefined because ‘c’ is empty:
b.getService = function(a) {
return cta || f]
}
In inspecting the resources loaded by the page, when the page does not contain a model, the file
skuid__SalesforceAdapterJS is not loaded (no script tag for it).
Currently, I don’t think the docs even mention the ability to create dynamic models using other adapters however this problem is bigger than just loading the salesforce adapter as the required adapter that the dynamic model needs would need to be loaded either on page load (not ideal) or on demand possibly during model.initialize() by inspecting the adapterName and checking to see if the adapter has been loaded yet.
Steps to reproduce:
- Create page from XML below (this is just a stock blank page)
- Preview page
Expected Result
Message “Successfully loaded!!” is output to console window
Actual Result
Javascript exception encountered -
"skuid__SkuidJS:formatted:11046 Uncaught TypeError: Cannot read property ‘getAdapter’ of undefined "
Sample Page XML
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true"> <models/>
<components/>
<resources>
<labels/>
<javascript>
<jsitem location="inline" name="newInlineJS" cachelocation="false" url="">(function($S, $){
var accountModel = new skuid.model.Model();
accountModel.objectName = 'Account';
accountModel.id = 'Account';
accountModel.recordsLimit = 1;
accountModel.fields = m
{ id: 'Id' }
, { id: 'Name' }
]
accountModel.initialize().register();
$.when(accountModel.load())
.done(function() {
console.log('Successfully loaded!!');
})
.fail(function() {
console.log('failed to load!!') ;
});
})(skuid, skuid.$);</jsitem>
</javascript>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>