Has anyone seen this when registering a page type ...
# suitecommerce
i
Has anyone seen this when registering a page type and trying to go to it? Says cannot 'get' of undefined.
define('Urb.UrbMyAccountsMods.RequiredPOSetting', [
'Urb.UrbMyAccountsMods.RequiredPOSetting.View'
],   function (
RequiredPOSettingView
) {
'use strict';
return  {
mountToApp: function mountToApp (container) {
var PageType = container.getComponent('PageType');
console.log('Wer made it!');
PageType.registerPageType({
name: 'myaccount_userpreferrences',
routes: ['preferences'],
view: RequiredPOSettingView,
defaultTemplate: {
name: 'urb_urbmyaccountsmods_requiredposetting.tpl',
displayName: 'User Preferences'
}
});
}
}
});
d
Extra reference to mountToApp in the function declaration?
s
Does that template exist?
i
Yes it does @Steve Goldberg
I even copy and pasted the file name to be sure
@Dominic B no the function still runs. It’s just the page that is broken
s
And is the view you're using extending the PageType.Base.View class?
i
Yes it is
// @module Urb.UrbMyAccountsMods.RequiredPOSetting
define('Urb.UrbMyAccountsMods.RequiredPOSetting.View'
,   [
    
'PageType.Base.View',
    
'urb_urbmyaccountsmods_requiredposetting.tpl'
    
]
, function (
    
PageTypeBaseView,
    
urb_urbmyaccountsmods_requiredposetting_tpl
)
{
    
'use strict';
    
return  PageTypeBaseView.PageTypeBaseView.extend({
        
template: urb_urbmyaccountsmods_requiredposetting_tpl,
        
getContext: function getContext() {
            
return {
                
message: 'Hello world!'
            
}
        
}
    
});
});
It's definitely something wrong with view because that is what is throwing the error
s
can you paste me the full error message pls?
i
@Steve Goldberg
This is the error when i go into the minified code
The error starts at the pageInfo.get("name")
s
Right. Usually that error only occurs when you try to use add a new instance of a page type through the CMS -- I assume you're not trying to do that?
i
No it's through an extension
s
OK I can't really tell what's going on. My only advice is to reset the code to a place where it works and go from there methodically. Ie, use my full source code for this extension and then just cut bits out until you figure it out
The
pageInfo
error should only occur if you try to use this page type by adding a new instance via the CMS
So if you're only using it in an extension I don't understand why it would come up
i
Okay yeah I'll do that thanks
s
I just realised something -- you're using 20.1 aren't you?
This specific thing was an issue with 20.1 and was changed in 20.2
If your view is not going to be CMS-createable then you need to use Backbone.View and not PageType.Base.View
From 20.2 onwards, PageType.Base.View was changed to allow it to be used in non-CMS-createable cases
@iSuite can you confirm?
i
@Steve Goldberg Shoot that makes sense. Yes still using 20.1
Should I use backbone.view or SCView?
s
Yes still using 20.1
You should have said you were using a SCA version not supported by the tutorial 😄
And as you're using 20.1, you won't be able to use SCView so you'll have to use Backbone.View
You'll need to make a number of other adjustments as you go through the tutorial
i
Just noticed that! My bad lol...