Ownership group field is getting empty in the list view of knowledge article

shaik riyaz1
Tera Contributor

We have enabled 'Ownership group' field in the knowledge article to trigger approvals through flow designer.

For the use case, setting ownership group field when the 'configuration item(ci owner group value)' field changes using client scripts and script include.

Ownership group field value is visible on the form but not on the list view. we tried setting it through business rule(after insert,update) but the approvals are not triggering.

 

Client script: (on change of configuration item field)

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        var kb1 = g_form.getValue('kb_knowledge_base');
        if (kb1 == 'dfc19531bf2021003f07e2c1ac0739ab' || kb1 == 'f812dd214f62f24058c72ae6f110c72d' || kb1 == 'a7e8a78bff0221009b20ffffffffff17') {
            if (g_form.getValue('language') == 'English' && g_form.getValue('cmdb_ci') == '') {
                g_form.setValue('ownership_group', '');
            }
           

        }
    }

    //Type appropriate comment here, and begin script below
    var kb = g_form.getValue('kb_knowledge_base');
    if (kb == 'dfc19531bf2021003f07e2c1ac0739ab' || kb == 'f812dd214f62f24058c72ae6f110c72d' || kb == 'a7e8a78bff0221009b20ffffffffff17') {
        var gr = newValue;
        if (newValue) {
            var ga = new GlideAjax('populateOwnershipKB');
            ga.addParam('sysparm_name', 'getOwnerGroup');
            ga.addParam('sysparm_sysUserID', gr.toString());
            ga.getXML(callback);
        }
    }

    function callback(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        if (answer) {
            g_form.setValue('ownership_group', answer);
        } else {
            g_form.setValue('ownership_group', '');
        }
    }
}
 
 
 
Need help in setting the value on list view

 

12 REPLIES 12

Then you need to check on other logic that is emptying the field again. With my BR it is still filled. If there is any BR, flow, policy or script that empties the field again, it won't show a thing. OOB the field stays filled.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Try this business rule 
select after insert and update

(function executeRule(current, previous /*null when async*/) {

if (current.cmdb_ci.changes() && current.cmdb_ci) {
var ci = new GlideRecord('cmdb_ci');
if (ci.get(current.cmdb_ci)) {
if (ci.owner_group) { 
current.ownership_group = ci.owner_group;
} else {
current.ownership_group = ''; 
}
}
}

})(current, previous);

Mark Manders
Mega Patron

If it is on the form view (including content), it should be on the list view as well. The field doesn't show value in one view and not on the other, if the value is indeed there.

Check the xml of the record. Do you really have a value in the field? Or is it just a value showing client side (on the form through a client script) and not saved to the server? Because if so, you need to update your logic.

Why not change it through a 'before BR', triggering on 'ci changes'? No need to have a client script call a script include and not doing what it should. And if it's before and the approval needs to happen after saving, it will take the new group.

 

But the issue you are describing is probably in the field not really being set (which the BR will also resolve). 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark