with value change back

// 1. Identify valid scenarios def isScenario1011 = (BBActionManual_c == 'MAV_DIR_BB_ACTION_1011' && HRStatus_c == 'A' && EmploymentCountry_c != 'RO' && SalesRP_c == 'N' && CED_c <= 0 && (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS')) def isScenario1012 = (BBActionManual_c == 'MAV_DIR_BB_ACTION_1012' && IncentiveType_c == 'BONUS' && HRStatus_c == 'A' && SalesRP_c == 'A' && CED_c <= 0) boolean isValidScenario = (isScenario1011 || isScenario1012) // 2. LOGIC: If it's a valid scenario, Consent MUST be 'Y' if (isValidScenario) { if (EmployeeConsent_c != 'Y') { // Force it to 'N' if they tried to uncheck it illegally setAttribute('EmployeeConsent_c', 'N') throw new oracle.jbo.ValidationException("Employee Consent is mandatory for this configuration.") } } // 3. LOGIC: If NOT a valid scenario, no one can change the field if (isAttributeChanged('EmployeeConsent_c') && !isValidScenario) { // REVERT: Get the value as it exists in the database def originalValue = getOriginalAttributeValue('EmployeeConsent_c') setAttribute('EmployeeConsent_c', originalValue) throw new oracle.jbo.ValidationException("You are not allowed to change Employee Consent for these values. Field has been reset.") }

Comments

Popular posts from this blog

dev7 from eror

EPA

Unified Currency Report- Krithika