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

@shaik riyaz1 

are you sure the field name cmdb_ci is correct on your table on which BR is written?

Are you sure that CI has support_group populated in it?

Are you sure Ownership Group field on your table on which BR is written is referring to sys_user_group table?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yeah all are correct

I just tried it myself with the most simple BR ever and it worked. The issue must be within the data as Ankur mentioned. This works without any script whatsoever.

MarkManders_0-1740566638191.png

MarkManders_2-1740566672503.png

 

 

 


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

Tried with before/after business rules, 

Ownership group is populating when the form is saved and in the list view it is setting empty and checked in XML and it is also empty.

 

shaikriyaz1_4-1740569265148.png

 

shaikriyaz1_1-1740568697599.png

shaikriyaz1_2-1740569132121.png

 

@shaik riyaz1 

in list view to work the CI field should change

You should select the new CI and save the record

Double click the field in list, select CI and click the Checkbox and record will be saved

Then your Before update BR will trigger and it will work

AnkurBawiskar_0-1740569545425.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader