11/25/2024 11:23:59 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.
|
|
|
|
Requiring Fields
Posted: 14 Apr 06 4:10 PM
|
what is the latest term abortion legal in the us is abortion legal in every state in the us online fiogf49gjkf0d So i was just messing around looking for a good way to check a form for required fields. This was built in:
strMsg = Application.Translator.Localize ("The following fields are required and ") & vbcrlf & _ Application.Translator.Localize("must be entered to insert the ticket:") & vbcrlf
If lveAccount.LookupID = "" Then blnPassedValidation = False strMsg = strMsg & vbcrlf & "Account" End If
If Not blnPassedValidation Then msgbox strMsg, , "SalesLogix - Customer Service" End If
What I don't like about it is that its not very scalable. Everytime I add a field I have to go in and add four lines of code to make it required. It seems like it would be better to iterate through all controls based on .Required = "T" For i = 0 to Form.ControlCount - 1 If Form.Controls(i).Required = "T" Then strMsg = strMsg & vbcrlf & "SOMETHING" blnPassedValidation = False End If Next
At first I thought that just by checking the required property it would not allow the form to be saved but that doesn't seem to be the case. The problem with my code above is that I'm not sure what to put into "SOMETHING". I don't want to use the control name cause that doesn't make much sense for the user unless their not using proper naming conventions..which of course I am. Does anyone have any ideas on this? Oh and by the way, my DevLogix book got delivered to my house today, so no more stupid questions(hopefully) after this one.
Thanks in advance all.
|
|
|
|
Re: Requiring Fields
Posted: 14 Apr 06 6:35 PM
|
fiogf49gjkf0d [EDIT] Appearently my formatting-fu is weak.. You could try something like the following
'set this global to the form dim dictControls
'put this in AXFormOpen or AXFormCreate set dictControls = CreateObject("SCRIPTING.Dictionary")
'call this sub to add controls to the dictionary. These will be checked by CheckControls 'the first parameter to .Add is the message you want to show, the second is the control itself sub AddControls dictControls.Add "Account", lveAccount dictControls.Add "SomeOtherControl", txtOtherControl 'add 1 more line of code for each control... end sub
'call this to see if we validated (based on text property of control not being "") 'you could put a check to see the TypeName of the control and look for some other 'property (i.e. .LookupID for a lookup) function CheckControls dim item dim strMsg dim blnPassedValidation blnPassedValidation = true strMsg = Application.Translator.Localize ("The following fields are required and ") & vbcrlf & _ Application.Translator.Localize("must be entered to insert the ticket:") & vbcrlf for each item in dictControls if dictControls(item).Text = "" then strMsg = strMsg & vbCrLf & item blnPassedValidation = false end if next if not blnPassedValidation then MsgBox strMsg, , "SalesLogix - Customer Service" end if CheckControls = blnPassedValidation end function |
|
|
|
Re: Requiring Fields
Posted: 19 Apr 06 9:31 AM
|
fiogf49gjkf0d Doug, thanks for the help, here's what i ended up doing:
aControlArray(0,0) = "lveAccount" aControlArray(0,1) = "Account" ... aControlArray(10,0) = "memDescription" aControlArray(10,1) = "Problem Description"
str = "The following fields must be corrected: " & vbcrlf
For iCount = 0 to Frm.ControlCount - 1 If Frm.Controls(iCount).Required = "True" Then If Frm.Controls(iCount).Text = "" Then For xCount = 0 to UBound(aControlArray) If Frm.Controls(iCount).Name = aControlArray(xCount,0) Then str = str & vbcrlf & aControlArray(xCount,1) & " is blank." blnError = True Exit For End If Next End If End if Next
str = str & vbcrlf & "The view will not save until they are fixed." If blnError = True Then msgbox str End If
well what do you think? i thought it was half-way clever...but more likely its run of the mill |
|
|
|
Re: Requiring Fields
Posted: 20 Apr 06 6:52 AM
|
xanax weed and beer xanax weed adderall website fiogf49gjkf0d Hmmm... I thought you could control required fields a couple ways
1) If there is a picklist associated with the field, edit the picklist and check the box that says "Required entry"
2) The SLX control on the form has a Property called 'Required' Check this to make the field required.
John G. |
|
|
|
Re: Requiring Fields
Posted: 21 Apr 06 4:19 AM
|
fiogf49gjkf0d I personally don't like the built in required stuff. It's not really flexible and there was some reason it annoyed me back in 6.1 so I developed my own AXFormValidate:
---- Begin Snip ---- Function AXFormValidate(Sender) dim stringMissing dim booleanIsValid dim booleanIsFormProcessed dim booleanResult dim integerResult On Error Resume Next booleanResult = false integerResult = 0 booleanIsValid = true booleanIsFormProcessed = false if (pickListType.Text = "") then if (stringMissing = "") then stringMissing = "Type" else stringMissing = stringMissing & ", Type" end if booleanIsValid = false end if if (pickListStatus.Text = "") then if (stringMissing = "") then stringMissing = "Status" else stringMissing = stringMissing & ", Status" end if booleanIsValid = false end if if (not (booleanIsValid)) then integerResult = MsgBox(Application.Translator.Localize("The following items must be filled in: " & vbCRLF & stringMissing), vbYes, Application.Translator.Localize("Validation")) booleanResult = false else booleanIsFormProcessed = AXFormProcess() if (not (booleanIsFormProcessed)) then integerResult = MsgBox(Application.Translator.Localize("'" & pickListType.Text & "' is restricted to one per account." & vbCRLF & "Please choose another type"), vbYes, Application.Translator.Localize("Validation")) booleanResult = false else booleanResult = true end if end if AXFormValidate = booleanResult ErrorCheck(Application.Translator.Localize("AXFormValidate:")) On Error Goto 0 End Function ---- End Snip ----
Basically stringMissing is built as you go to result in saying something like "The following fields are not filled in: Type, Status". I could refactor the code by placing all of the Control.Name strings into an array. Loop through the array to see if Control.Text = "". If true, stringMissing = Control.Caption. I can't simplify it much beyond that. |
|
|
|
Re: Requiring Fields
Posted: 21 Apr 06 4:41 AM
|
fiogf49gjkf0d Never mind. Control.Caption only mattered in Legacy since each control had their own label. I would have to use a 2 dimensional array or some form of 1 dimensional string manipulation (Control:Caption for instance). I don't use Control.Required properties because they tended to interfere when I ran my own in AXFormValidate. Basically the same thing just worded differently. |
|
|
|
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!
|
|
|
|
|
|
|
|