We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Auto fill Service when entering Service Offering in Change form.

Patrick Brown
Tera Contributor

Newby here.  I'm labbing up the Change form in a Zurich based PDI.

 

I'm working on Services and Service Offerings.  I have services created in table 'cmdb_ci_service_technical'.  I have service offerings in table 'service_offering'.  The Services are set as the parent on the offerings.  I'm using CSDM5.

 

I want to configure my Change form to auto fill the Service when the Offering field is entered.  Services will become read only when I figure this out.

 

I have this script assigned to the Service offering field as an onChange.

 

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

    if (!newValue) {
        g_form.clearValue('business_service');
        return;
    }

    g_form.getReference('service_offering', function(offering) {
        if (offering && offering.service) {
            var serviceId = offering.service.toString();
            g_form.setValue('business_service', serviceId);
        } else {
            g_form.clearValue('business_service');
        }
    });
}

 

If I enter the offering, I get an Invalid reference error.  Any ideas?  Maybe a howto doc on how to make this work?

 

Thanks All,

 

--Patrick

1 REPLY 1

fknell
Giga Patron

Hi @Patrick Brown,

The Business Service and the Technical Service Offering do not have a direct relationship to query.

 

IMG_7376.jpeg

How are you going to find a unique value for the Business Service field with a given TSO? There are multiple n:m relationships between this two entities.