Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to import data into service offering table based on parent(cmdb_ci_service)

vamshi2
Tera Contributor

Hi team

 

Please advice to import data into service offering table based on parent(cmdb_ci_service) service classification is business or technical service

NameParentService classification
abcoaoStorage ManagementBusiness Service
sdsnkjkjStorage ManagementTechnical Service

 

 

i used below script for parent field but not working please suggest 

 

answer = (function transformEntry(source) {

    // Add your code here
    //Used to check service classification and import
    var sourceparentdata = source.u_parent;
    var sourceserdata = source.u_service_classification;
    var sourcechilddata = source.u_name;

    if (sourceserdata == "Business Service") {
            var parenttsData = new GlideRecord('cmdb_ci_service');
        parenttsData.addEncodedQuery('service_classification=Business Service^name=' + sourceparentdata);
        parenttsData.query();
        if (parenttsData.next()) {
            answer = parenttsData.name;

        } else {
            ignore = true;
        }
        return answer;
    }


})(source);
1 ACCEPTED SOLUTION

Community Alums
Not applicable

@vamshi2 You need to set answer to the sys_id of the parent service record, not the name, because the parent field is a reference field.

Also verify that you only handle the "Business Service" classification but don't specify what to do if the service_classification is "Technical Service."

Hope this will help you.

View solution in original post

1 REPLY 1

Community Alums
Not applicable

@vamshi2 You need to set answer to the sys_id of the parent service record, not the name, because the parent field is a reference field.

Also verify that you only handle the "Business Service" classification but don't specify what to do if the service_classification is "Technical Service."

Hope this will help you.