wth debug
// 1. Log the checkbox status
println("DEBUG: EmployeeConsent_c value is: " + EmployeeConsent_c)
if (EmployeeConsent_c == true) {
// 2. Access the Attachment collection
// Note: If 'Attachment' fails, try 'Attachment_c' or check the object definition
def attachmentRows = Attachment
// 3. Log if the collection exists
if (attachmentRows == null) {
println("DEBUG: Attachment collection is NULL")
return false // Trigger error: No collection found
}
// 4. Count the attachments
attachmentRows.reset() // Start at the beginning
int count = 0
while (attachmentRows.hasNext()) {
attachmentRows.next()
count++
}
println("DEBUG: Total attachment count found: " + count)
// 5. Trigger error if count is 0
if (count == 0) {
println("DEBUG: Validation FAILED - No attachments found")
return false
}
}
println("DEBUG: Validation PASSED")
return true
Comments
Post a Comment