I have a BO TimeObject with the following attributes:
Name: EndTime, type: Timestamp, calculated: yes
Name: EndTimeText, Type: Plain Text, Max. length: 5, input mask: /^[012]\d:[012345]\d/
Name: StartTime, type: Timestamp, calculated: yes
Name: StartTimeText, Type: Plain Text, Max. length: 5, input mask: /^[012]\d:[012345]\d/
Name: WorkDate, Type Date
With the following rules:
1) TimeObject.StartTime=AS_TIMESTAMP(AS_STRING(TimeObject.WorkDate)+' '+TimeObject.StartTimeText,'yyyy-MM-dd HH:mm')
2) TimeObject.EndTime=AS_TIMESTAMP(AS_STRING(TimeObject.WorkDate)+' '+TimeObject.EndTimeText,'yyyy-MM-dd HH:mm')
3) TimeObject.EndTimeText=AS_STRING(AS_NUMBER(CHARS_FROM_LEFT(TimeObject.StartTimeText,2))+1)+CHARS_FROM_RIGHT(TimeObject.StartTimeText,3)
Rule 3 is suppose to set the EndTimeText to 1 hour after the StartTimeText
All rules are set to use in dynamic re-calculation on forms.
Only WorkDate and StartTimeText are on the form.
When I try to create an object, I enter the WorkDate (05/01/2009) and StartTimeText (12:34) and hit the create button.
I get the progress bar that the information is being submitted and then a new blank form with no errors.
When I search for the object I just created, I can not find it. It does not appear to get written to the database.
After much investigation, the problem appears to be with rule 3 above.
The AS_NUMBER() function returns a float number instead of an integer, as I expected, and EndTimeText is being set to 13.0:34 which is an invalid format.
I believe that I should have gotten some kind of error. Either an invalid format for EndTimeText or a failure trying to write to the database.
If I add EndTimeText to the form, I do get an invalid format error, but I do not want it on the form.
I was able to get this to work by changing rule 3 to:
If TimeObject.StartTime IS DEFINED Then
TimeObject.EndTimeText=SUBSTRING(AS_STRING(TIME_ADD(TimeObject.StartTime,1)),11,16)
As a side point, shouldn't AS_NUMBER return an integer if there is no period in the string?