The word 'Null' appearing when clearing out the value within a field on an application service

matthew_hughes
Kilo Sage

On an application service record, the name field is made up of the Business Application Name and Instance Descriptor field:

 

matthew_hughes_0-1741593066054.png

 

What we've noticed is that if a user clears the Instance Descriptor field manually within the form, it updates the Name to just reflect the Business Application Name field as expected:

matthew_hughes_1-1741593311960.png

 

A user who doesn't have access to the application services table can carryout this amendment via a Data Only change request:

matthew_hughes_2-1741593482195.png

So a user can clear out the Instance Descriptor field and click Save Proposed Changes

 

Once the change record has been approved, the user can then click on the Apply Proposed Changes button:

matthew_hughes_3-1741593618404.png

 

However, what we've noticed is that when a user clicks on Apply Proposed Changes, the Instance Descriptor field does get cleared out as expected, but the Name field includes the word Null instead of just updating the Name with just the Business Application Name value:

matthew_hughes_4-1741593707905.png

 

matthew_hughes_5-1741593844676.png

 

The change is triggered by the following Business Rule:

matthew_hughes_6-1741593955539.png

The below code is from within the Advanced tab:

if (current.operation() == "update" && current.u_bus_app_name != '') {
        if (current.u_instance_descriptor.changes()) {
            if (current.u_instance_descriptor != '' && current.u_instance_descriptor != 'NULL') {
                gs.log("KM2 Instance Descriptor first block: "+current.u_instance_descriptor);
                current.name = current.u_bus_app_name.name.toString() + "_" + current.u_instance_descriptor;
            } else if (current.u_instance_descriptor == '' || current.u_instance_descriptor == NULL || current.u_instance_descriptor == 'NULL' || current.u_instance_descriptor == null || current.u_instance_descriptor == 'null'|| current.u_instance_descriptor == '_NULL') {
                gs.log("KM2 Instance Descriptor second block: "+current.u_instance_descriptor);
                current.name = current.u_bus_app_name.name.toString();
            }
        }

    }

 

 

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@matthew_hughes 

so what's your analysis for the above business rule when you added logs?

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

Hi,

 

The results of the logs are below:

matthew_hughes_0-1741595612034.png

 

@matthew_hughes 

is the field name u_instance_descriptor correct and is on same table where business rule is running?

I assume it's not a dot walked field added on form via some other reference field?

what happens when you run as admin?

It's going inside that 2nd block because it's unable to fetch the value

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

Hi @Ankur Bawiskar  Yes so the 'u_instance_descriptor' is on the 'cmdb_ci_service_discovered' table.