To approach this requirement in ServiceNow, I'd suggest the following steps:
1. Design the Form and Fields
- Create a new customer creation request form (e.g., a Catalog Item or a Form) with a field for the unique identifier (e.g., VAT Number).
- Make this field (VAT Number) a mandatory field to ensure it's always populated.
2. Create a Web Service to interact with the Master Data System
- Identify the API or web service provided by the master data system to check for existing customers.
- Create a new Web Service in ServiceNow (using the "Web Service" module) to interact with the master data system's API.
- Configure the Web Service to send a request with the VAT Number and retrieve a response indicating whether a customer with that VAT Number exists.
3. Use a Client Script or Business Rule to call the Web Service
- Create a Client Script (JavaScript) or a Business Rule (on the form) that will be triggered when the VAT Number field is populated.
- In the script/rule, use the Web Service to send a request to the master data system with the VAT Number.
- Parse the response to determine if a customer with the provided VAT Number exists.
4. Display the Result to the User
- Based on the response from the master data system, display a message to the user indicating:
- If a customer with the provided VAT Number already exists (e.g., "Customer already exists, please use the existing customer record").
- If no customer with the provided VAT Number exists (e.g., "Customer not found, please proceed with creating a new customer").
5. Implement Duplicate Prevention Logic
- If a customer with the provided VAT Number already exists, prevent the user from proceeding with creating a new customer record.
- You can achieve this by:
- Disabling the form's submit button.
- Displaying an error message that prevents the user from saving the record.
6. Optional: Use a GlideForm and Async Script
- If you prefer a more modern approach, you can use a GlideForm (a client-side form rendering) and an async script to achieve the same result.
- This approach allows for a more responsive and dynamic user experience.
Example Code (Client Script)
// Client Script example
function onChangeVATNumber() {
var vatNumber = g_form.getValue('vat_number');
var webService = new GlideWebService('https://your-master-data-system.com/api/customers');
var request = {
'vat_number': vatNumber
};
webService.get('exists', request, function(response) {
if (response.exists) {
g_form.setError('vat_number', 'Customer already exists, please use the existing customer record');
g_form.setDisabled('submit', true);
} else {
g_form.clearError('vat_number');
g_form.setDisabled('submit', false);
}
});
}
This is a high-level overview of the approach. The actual implementation details may vary depending on your specific ServiceNow instance, the master data system's API, and your organization's requirements.