How to Populate Serial number Based on Configuration Item on Call entry form????

Divya K1
Tera Guru

Hi,

 

How to populate Serial number based on Configuration item selected on call entry form when the call entry ticket submitted?

Screenshot 2023-12-18 182041.png

 

2 REPLIES 2

SunilKumar_P
Giga Sage

Hi @Divya K1 ,

 

You can populate the Serial Number by doing a GlideAjax. The below scripts should populate the Serial Number on selection of CI.

 

Script Include:

 

var GetSerialNumber = Class.create();
GetSerialNumber.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getSerialNum: function() {
        var ci = this.getParameter('sysparm_ciName');
        var item = new GlideRecord('cmdb_ci');
        if (item.get(ci)) {
            return item.serial_number;
        }
    },
    type: 'GetSerialNumber'
});
 
Client Script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }

    var item = g_form.getValue('ci');
    var gr = new GlideAjax('global.GetSerialNumber');
    gr.addParam('sysparm_name', 'getSerialNum');
    gr.addParam('sysparm_ciName', item);
    gr.getXML(getLoc);

    function getLoc(response) {
        var answer = response.responseXML.documentElement.getAttribute("answer");
        alert(answer);
        g_form.setValue('serial_number', answer);
    }
}

 

SunilKumar_P_0-1702905483428.png

SunilKumar_P_1-1702905503842.png

SunilKumar_P_3-1702905594866.png

 

Regards,

Sunil

 

AndersBGS
Tera Patron
Tera Patron

Hi @Divya K1 ,

 

In what table / class are your serial number populated? And in which table / class do you need to populate it? In general cmdb_ci can be utilized, but would minimize the queary load if possible.

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/