7/7/2025 2:30:06 PM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
AXFormValidate does not trap all exits from form
Posted: 01 Oct 08 2:16 PM
|
I have a problem with AXFormValidate. I am trying to make sure that a user can not leave a date field blank when a picklist contains a certain value. It all works fine as follows if you save the record or scroll to the next record:
Function AXFormValidate(Sender) 'Rev: 7.02 Added if pklStatus.Text = "Inactive" then If instr(pklReason.Text,"Future Opportunity") > 0 then If dteFocusDate.datetime <= date() then msgbox "Focus date must be set greater than today ..." AXFormValidate = False dteFocusDate.SetFocus end if end if end if End Function In this case the record is not changed and the focus is set on the date field properly.
However .... When you exit the form by using a lookup, you are prompted to save, the validation code runs, but setting AXFormvalidate = false does not stop the record from changing, hence the value you wanted to validate is not set.
Any idea anyone?
Steve |
|
|
|
Re: AXFormValidate does not trap all exits from form
Posted: 07 Oct 08 9:32 AM
|
Try the following, I think this will meet your needs:
Use the form's ONBEFORERECORDCLOSE event (This is a sub and not a function - so you can't return false to prevent the navigation)
-capture the id in a global variable -capture the validation result in a global variable -in the ONCHANGE event of the form, 1) check the two variables for data - particularly the validation result for true or false 2) If you find the validation event returned false, navigate back to the record using any of the standard methods of doing so with the id you captured before navigation occured.
|
|
|
|
Re: AXFormValidate does not trap all exits from form
Posted: 07 Oct 08 10:12 AM
|
Thanks Matt.
I will try that. It seems to me that the Validate should trap all exits, otherwise your data will not be checked for validity. Do you think this is a bug? Or will they just ignore it and say "as designed".
Steve |
|
|
|
Re: AXFormValidate does not trap all exits from form
Posted: 09 Oct 08 8:42 AM
|
It's been an issue for a long time across multiple versions. Data validation in SLX is a nightmare since the tabs and multiple views aren't really aware of each other (intrinsically atleast), and the Sage Application development team doesn't really care so long as those of us in the field can come up with these workarounds unfortunately (or so it seems). |
|
|
|
Re: AXFormValidate does not trap all exits from form
Posted: 22 Jun 10 8:26 AM
|
For some reason I think this traps all Button clicks with a modality of mrOK. Not all events, Not clicking on the Cancel button (mrCancel is the modality), nor the X window button, or hitting ESC. Not clicking on a nonModal button (mrNone = modality). Not handling scripts or Lookups that might close the form in other ways.
Basically AXFormValidate prevents closing of the form via an mrOK modal button, even though the user has clicked on the button which means run any script in the button onclick event, CLOSE THE FORM AND SAVE THE DATA. AXFormValidate is an override. You pass it values through globals or form controls (or the form itself). It evaluates these non input parameter inputs, you set AXFormValidate to True the form closes and saves the data. You set AXFormValidate to False the form doesn't close and it doesn't save any databound data.
I've always coded this as follows:
OnButtonClick of the OK button:
check some stuff out set an OKToCloseForm global variable to true or false,
If OKToCloseForm: set your final form closing stuff. Else msgBox " Dear User: you've forgotten to fill in the following required fields.....",,"Validation Error" '''' OKToCloseForm = False of course. exit the button on click event handler End IF End Sub
Now this will always close the form as its modality is mrOK. ALWAYS.
Unless you override it with form level event AXFormValidate.
AXFormValidate fires off after an mrOK button event handler has fired. that means AFTER the onclick event stuff has fired.
Sub AXFormValidate: AXFormValidate = False If OKToCloseForm Then AXFormValidate = True End Sub
Does that make sense? |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|