Hi,I've a replicant Item (File Path) in my DCT form. I need to validate the size for all the files from replicant items (File Path Items) I am using call server to find out the attachment size, Iam trying to invoke onSave event to get the file size. As Call server is asynchronous, I could not able to stop the process until call server process completed. Based on the file size validation from call server, I need to provide alert message to the user.Please suggest how to make the control, to wait till call server completed.I found some timeout concept. But I am not sure how it will work. Pls provide any pointers useful for my request.Env: Teamsite 6.0 & UnixThanks in advance,MSR
Thanks for your reply.I tried with second option (i.e create two call-back functions). If the validation successful then calling saveAndClose callback function. If the validation fail calling warnAndContinue callback function. warnAndContinue callback function is just giving alert message to the user. If I click on 'Generate' button proceeding to generate the html page. But it should not allow generate process. Pls suggest how to stop the generate process if the validation fail.In the first option i.e onSaveValid, I can return false unconditionally.But Iam not sure, how can I continue save process from the call server.[ i.e Giving option to the user to save the DCR from call server]Thanks in advanceMSR.
Why dont you do the filesize check on Itemchange Event in the replicant fields. Once the value in the field changes (on Itemchange event) you can do the callback to retrieve the filesize and save it in some JS variable. Keep doing it for all the replicant items and display all the values at once on "onSave" events. That ways you will not have to worry about Callback async. issues.
I thought about suggesting that too - but you still have async issues to consider and also I'm not sure if the onItemChange event fires when the browser selection is submitted or when the focus leaves the field into which the value was populated. If the latter, and the user attempts to save the DCR directly after selecting a file you might be missing the file size data for that one element - so you'd have to do another callServer in the onSaveDone event if there is no data there. It gets more complicated (if the event doesn't fire until an explicit change of focus) because if one file was selected and the size data populated and then they decide to choose a different file ... if the data isn't re-calculated you might be validating incorrect data.Of course, if the event does fire when the browser item is submitted, then the first thing your event handler should do is clear out the old file size data before trying to fetch new file size data -- but there's still a possiblity of a race condition between that asynchronous call and the save process...
It is fired when browser selection is submitted. So your scenario should not exist.i dont think that there is any possibility of race condition between async call and Save Process in this case (unless until the callback takes huge time to retrieve the file size from server but i assume that should not be a problem).
I beg to differ. OnItemChange fires when the focus leaves the field. So it is possible that someone would click save immediately after changing the field. While a race condition is possible, I agree is it quite unlikely. From all the FormAPI and call servers I have done, I have never found this to be an issue (but also do not think I ever tested it)
ok, here is what i just tested out. if you use the "text" item, the "onitemchange" is fired when you explicitly leave the focus from that field. BUT if you use the "browser" item, "onitemchange" is fired once you select the value through the "browse". So even if somebody would click save immediately after changing the field (As this field is capturing the file path, i would assume that browser option would be used), file size can always be captured using onitemchange.