Change childOrder on create using content lib


#1

Enonic version: 6.15.0
OS: Windows 10

I need change order of content in content studio. By default the ordering is modified time DESC, but i need in modified time ASC. Is possible create a node with this parameter? I trying this, but not change after publish content. This is an example of my code

contentLib.create({
        parentPath: '/' + app.name + '/myFolder',
        name: myName,
        branch: 'draft',
        contentType: app.name + ':mycontenttype',
        language: 'no',
        data: data
        x: {},
        attachments: {},
        _childOrder: 'modifiedtime ASC' // This not working
 })

#2

Hi, and sorry for the delayed response.

This is a well-known issue which has now been scheduled for the next release. You can follow up its status here.


#3

Thanks for answer, @ase. Meanwhile i use the webservice call. If someone need this, this is my code:

function changeChildOrder (id, fieldName, direction) {
httpClientLib.request({
url: baseUrl + ‘admin/rest/content/setChildOrder’,
method: ‘POST’,
headers: {
‘Accept’: ‘application/json’
},
auth: {
user: ‘’,
password: ‘’
},
contentType: ‘application/json;charset=UTF-8’,
body: JSON.stringify({
silent: false,
childOrder: {
orderExpressions: [{
FieldOrderExpr: {
fieldName: fieldName,
direction: direction
}
}]
},
contentId: id
})
})
}