views:

36

answers:

1

Could you give me an example of the way I should code into the pfc_Validation event? This is an event that I have never used. For example here is something I have coded in the ue_itemchanged event.

if dwo.name = 'theme' then  
   This.Setitem(row,"theme",wf_clean_up_text(data))
end if

if dwo.name = 'Comments' then  
   This.Setitem(row,"Comments",wf_clean_up_text(data))
end if

Which is the proper way of coding those validations in the pfc_Validation event , so that they are performed only on save-time?

+3  A: 

You're asking something outside of native PowerBuilder, so there's no guarantee my assumptions are correct. (e.g. anyone could create a pfc_Validation event and have it fire when the user draws circles with his mouse) There is a pfc_Validation event coded as part of the Logical Unit of Work (LUW) service in PowerBuilder Foundation Classes (PFC). If you want to find out more about it, I've written an article on the LUW.

Firstly, your question: Everything in the LUW service is only fired at save time, so you're in good shape there.

Having said that, from the looks of the code, this isn't validation, but data preparation for the update. On that basis, I'd suggest the appropriate place for this logic is pfc_UpdatePrep.

As for converting the code, it's pretty simple. (Now, watch me mess it up.)

FOR ll = 1 to RowCount()
   Setitem(ll,"theme",wf_clean_up_text(GetItemString (ll, "theme")))
   Setitem(ll,"comments",wf_clean_up_text(GetItemString (ll, "comments")))
NEXT

Good luck,

Terry.

Terry