Business Rule to make the "supplier company" field empty on the basis of conditions.

Chhavi Dixit
Tera Contributor

Hi Everyone,

 

Need to create a Business Rule to make the "supplier company" field empty upon the condition if "employee type" field changes and "supplier company" field is not changed in both UI and LDAP.

 

Thanks!

Chhavi Agnihotri

1 REPLY 1

Pratiksha
Mega Sage
Mega Sage

Before BR, update should be checked. 

 

function executeRule(current, previous /*null when async*/) {

// Check if 'employee type' has changed
if (current.employee_type.changes()) {

// Check if 'supplier company' has NOT changed in UI
var supplierUnchangedInUI = !current.supplier_company.changes();

// Check if value has not changed from LDAP (i.e., previous value remains)
var supplierUnchangedFromLDAP = current.supplier_company == previous.supplier_company;

if (supplierUnchangedInUI && supplierUnchangedFromLDAP) {
current.supplier_company = ''; // Clear the field
}
}