I have a field that I am setting to disabled using the below logic.
/** Disables the official entry text field if viewer is not "assigned to" employee to prevent changes to the official entry by others than the owner */ protected boolean isOfficialEntryDisabled() { if ( session.employeeLoggedIn == reportEntryItem.employeeassignedto() ) { return false; } return true; }
Other elements of this object can be updated at will and the system performs as expected. However, if an admin (who is allowed to change the employeeassignedto relationship) changes the employee this record is assigned to, the system assumes the field is null.
Restated, it appears that when the field is disabled, and the record is changed so the current logged-in employee becomes the owner, EO believes the field is null (checked the SQL logs to determine this). Oddly, this behavior does not occur when changing any other field, or even changing the owner to an employee other than the one logged in.
Some more relevant code:
FROM COMPONENT EntryEditPage /** Saves changes to this segment ReportEntry and returns user to EntryListPage page. */ protected EntryListPage saveEntry() { reportEntryItem.setLastUpdateTime( new NSTimestamp() ); // sets last update time to current time reportEntryItem.setEmployeelastupdated( session.employeeLoggedIn ); // sets last update by to person logged in reportEntryItem.setWordCount( reportEntryItem.numberOfWords( reportEntryItem.reportEntry() ) ); // sets wordCount for this entry. ec.saveChanges(); EntryListPage nextPage = (EntryListPage)pageWithName("EntryListPage"); return nextPage; }
FROM CLASS ReportEntry /** Counts the number of words in a given lenght of text. If the incoming text is null, word count is returned as zero. */ public int numberOfWords( String aLengthOfText ) { if ( null == aLengthOfText ) { return 0; } StringTokenizer st = new StringTokenizer( aLengthOfText, " " ); return st.countTokens(); }
|