Revision one above worked, but wasn't good enough for them since it left out the "Back from Customer"notes.
This is what I came up with and it works using the "Test Calculation", but it isn't working properly in Web Desk.
import System
static def GetAttributeValue(Incident):
Value = 'Most recent note or With Customer details:'
Value += '\n'
if Incident.Status.Title == 'With Customer':
if Incident.Notes.Latest() != null:
if Incident._WithCustomerCol.Latest()._Createdon.ToLocalTime() > Incident.Notes.Latest().CreationDate: Value += Incident._WithCustomerCol.Latest()._Details
else: Value += Incident.Notes.Latest().Text
else: Value += Incident._WithCustomerCol.Latest()._Details
elif Incident.Status.Title != 'With Customer':
if Incident._BackFromCustomerCol.Latest() != null and Incident.Notes.Latest() != null:
if Incident._BackFromCustomerCol.Latest()._Createdon.ToLocalTime() > Incident.Notes.Latest().CreationDate: Value += Incident._BackFromCustomerCol.Latest()._Description
else: Value += Incident.Notes.Latest().Text
elif Incident._BackFromCustomerCol.Latest() == null and Incident.Notes.Latest() != null: Value += Incident.Notes.Latest().Text
elif Incident._BackFromCustomerCol.Latest() != null and Incident.Notes.Latest() == null: Value += Incident._BackFromCustomerCol.Latest()._Description
else: Value += 'No recent notes'
else: Value += 'No recent notes'
return Value
The Calculation is set to After Read.
Test 1 -- Most recent item is "Back from Customer" and it is displaying Note that was entered prior
Test 2 -- Most recent item is "With Customer" and it is displaying Note that was entered prior
Test 3 -- Most recent item is Note after Back from Customer -- working
Test 4 -- Most recent item is Note after With Customer -- working
All four scenarios work w/ the "Test Calculation" button, but 1 & 2 fail in Web Desk