Issue with Populating 'Customer' Field from Reference Table in ServiceNow

NikhithaNikki
Tera Contributor

I am experiencing an issue with a select box field named "customer" in ServiceNow. The field has the following choices and backend values:

  • Very Low (1)
  • Low (2)
  • Moderate (3)
  • High (4)
  • Very High (5)

This field is populated from the cmdb_ci_business_app table using dot-walking. When I select "existing digital platform," the customer field should be populated from the table. However, if the customer value is empty (none), it should display as "None" or remain empty in the form. Currently, it is showing as '0'.

Could you please help me understand why this is happening and how to fix it?

Thank you!


I have created on change clent script for populating field as none when there is no customer value. 

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

    var customer = g_form.getValue('customer_1');
    alert(customer); // Corrected alert to show the value of customer

    if (customer === '0' || customer === undefined || customer === '') {
        alert("Test");
        g_form.addOption('customer_1', '-1', '-- None --'); // Add option with value '-1' and display '-- None --'
        g_form.setValue('customer_1', '-1'); // Set the actual value to '-1'
    }
}

 

 
 
 
 
 
 
 
 
1 REPLY 1

GlideFather
Tera Patron

Hi @NikhithaNikki
just an idea... could you try to create a default value for that variable/field to be  -- None -- ?

But it must be secured if a value in Customer is selected and then removed... it should be reflected as well.

PS: Just a curiosity.. isn't it a misleading name for this field? Customer with options 1 to 5? I would expect a reference to Customer Accounts, Names, but the scale 1 to 5 should be something else Customer level, Customer Priority, etc...

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */