Admin Tool - portalLib.url is not a function

Enonic version: 6.10.1
OS: OSX

When copying and pasting example code at http://xp.readthedocs.io/en/latest/developer/admin/tools/index.html I get the following error:

com.enonic.xp.resource.ResourceProblemException: TypeError: portalLib.url is not a function (java.lang.RuntimeException)

Has there been any changes that we should be aware of?

Hi,

Can you paste the code you are running, please? Example code doesn’t include “require” part, so that might be an issue.

Hi!

I’m running the exact same code as on the given link, except for that i have required portal

var portalLib = require('/lib/xp/portal');

Edit: Some methods on portalLib works… like serviceUrl

Just tried it. If I use it exactly like in the docs, which is:

var portal = require('/lib/xp/portal');
var url = portal.url({
    path: '/portal/master/mysite',
    params: {
        a: 1,
        b: 2
    }
});

log.info(url);

then I get the url that ends with ?message=URI+out+of+scope but that’s because my site doesn’t have "mysite" page as in the docs. But the url method itself works fine.

My previous answer was not entirely spot on. Result url will get “?message=URI+out+of+scope” in the end when tested in preview mode (or in admin). But when content is viewed in live mode then everything works fine and url will be correctly generated even if the page doesn’t exist on the site.

Did you figure out why you got the error or are you still getting it?