How do I retrieve the URL field value from a contentlet which is used as a page content type?

Skip to first unread message

Bart Plasmans

Dec 23, 2021, 10:02:32 AM12/23/21
to dotCMS User Group

how are you doing ?
I ran into an issue trying to read the  "url" field value of a content we use as page content.
The value for the field "url"is set in the dotCMS admin for all pages.

In the content type screen the field properties have been set to : 

 -Name: Url
- Variable:url
- Required 
- User Searchable
- System Indexed
- Show in List

When using the ContentletAPI.find  all fields are filled in the response Contentlet, however the "url" field is always "null". 

Contentlet pageContent = APILocator.getContentletAPI().find(pageId, APILocator.getUserAPI().getSystemUser(), false);

Does anyone know if we do something wrong? 

We found an ugly workaround using the dotCMS viewtool "com.dotcms.rendering.velocity.viewtools.content.ContentTool.find()" method.

This returns only the contentmap for a Contentlet, and there the field "Url" is filled:
ContentMap pageContentMap = contentTool.find(page.getInode()); 

Can anyone assist in why the "Url" field is not filled? 

Thank you!

Will Ezell

Dec 29, 2021, 1:59:31 PM12/29/21
You need to use the HTMLPageAssetAPI and do something like

HTMLPageAsset asset = APILocator.getHTMLPageAssetAPI().findPage(pageId, APILocator.systemUser(), false);


Or if you have the contentlet:


HTMLPageAsset asset = APILocator.getHTMLPageAssetAPI().fromContentlet(contentlet);

-- - Open Source Java Content Management
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit


382 NE 191st St #92150
Miami, Florida 33179-3899
305-900-2001 | Direct: 978.294.9429

Reply all
Reply to author
0 new messages