Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
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!
 Architect Forums - Legacy Development
Forum to discuss SalesLogix legacy development including views, scripts, etc.. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Legacy Development | New ThreadView:  Search:  
 Author  Thread: Legacy Ticket Validation
Sarah Peterson
Posts: 37
 
Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jan 07 11:16 AM
fiogf49gjkf0d
If a user closes the Support Ticket screen and the ticket is not Closed but does not have a follow-up date or it has an over-due follow-up date I need to display a message, put focus back on the date field, and keep the view from closing. The following code is what I have added to the META Ticket Punch Out On Close script of the form. I have tried adding the CloseCurrentView function as the first statement and as the last statement with in the If...Then...Else but get bad results!

When the code is like this, the Support client hangs up...
IF getpropertyof("plstatus", "text") <> "Closed" and getpropertyof("deNeededDate", "text") = "" then
CloseCurrentView True
setproperty "postable", "False"
ControlDo "deNeededDate", "Focus"
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
END IF

IF getpropertyof("plstatus", "text") <> "Closed" and getpropertyof("deNeededDate", "text") = "" then
setproperty "postable", "False"
CloseCurrentView True
ControlDo "deNeededDate", "Focus"
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
END IF

IF getpropertyof("plstatus", "text") <> "Closed" and getpropertyof("deNeededDate", "text") = "" then
setproperty "postable", "False"
ControlDo "deNeededDate", "Focus"
CloseCurrentView True
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
END IF

When the code is like this, I end up in a never-ending loop...
IF getpropertyof("plstatus", "text") <> "Closed" and getpropertyof("deNeededDate", "text") = "" then
setproperty "postable", "False"
ControlDo "deNeededDate", "Focus"
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
CloseCurrentView True
END IF


I cannot find any documentation anywhere that would discuss the proper way to keep a legacy form from closing. Any suggestions? This is a rather urgent issue; not having this validation caused a mark against us during a security audit.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jan 07 2:40 PM
fiogf49gjkf0d
SetProperty "Postable", "False" means do NOT post the form to the database and stop all processing. CloseCurrentView in turn closes the view in either the OK (false) or Cancelled (true) state (though I may have the booleans backwards).

Here's an example from the 6.1 LAN Developer's reference for SetProperty (it's useful to keep this version around if you're working in Legacy land, otherwise stick to the one that matches your SLX version):

If Len(GetPropertyof ("txtFirstName", "Text")) = 0 Then
SetProperty "Postable", "False" 'Do not post changes
Else
SetProperty "Postable", "True" 'Post changes
End If

If you set postable to false, it will have to be set back to true for the form to record changes. That is most likely the problem you're facing. I'd put your CloseCurrentView code after setting postable to true because that's the only time you want the form to close when the OK button is pressed. I'd even use the example to form your if..else statements, just placing CloseCurrentView under the else block *edit: AFTER SetProperty.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jan 07 2:53 PM
fiogf49gjkf0d
To make things easier I'll just rework the code you posted into what I'd use:

If ((GetPropertyOf("plstatus", "Text") <> "Closed") and (GetPropertyOf("deNeededDate", "Text") = "") Then
SetProperty "Postable", "False"
ControlDo "deNeededDate", "Focus"
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
' Do NOT CloseCurrentView. Keep the form open until validation returns no errors.
Else
SetProperty "Postable", "True"
CloseCurrentView False ' OK clicked
End If

One thing I forgot to mention: In v6 you have to turn off the ModalResult of the OK button or else it'll close regardless of validation. If this is necessary then immediately after DisplayValidationMessage is called, the form would close regardless (it's supposed to stay open until Cancel is clicked or it validates when OK is pressed). The last Legacy work I did was back in v5.2 and that was a very long time ago now, so I can't remember if it's necessary or not.
[Reply][Quote]
Sarah Peterson
Posts: 37
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jan 07 3:05 PM
fiogf49gjkf0d
Thanks but I get the same results. When I put the CloseCurrentView code after the SetProperty of the ELSE block, the Ticket screen still closes. I get my message box but the screen closes anyway. I tried using both true and false thinking maybe I had them backwards but both results land me back to where I was.

When I move the code up to after the SetProperty of the If statement (just for grins) I end up in an infinite loop. I've moved the code to other scripts as well. I can get it to work in the META Ticket When Validate script however since it is in the validation it doesn't work the way we need it to. Having it here would make all tickets, closed or not, require a follow-up date. So, I have now moved the code back to where I believe it needs to be...the META Ticket Punch Out On Close, on the When Close event of the Ticket form.

Any other thoughts? Thanks again...
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Jan 07 6:08 PM
fiogf49gjkf0d
The order I believe is typically OnValidate, OnCloseQuery, then OnClose. On/WhenValidate is fired before the form is posted to the database. This is where you'd trap all validation for the database, to keep it simple this is also where I stop the form from closing. OnCloseQuery is a recent addition I thought, and I'm not sure they backport that stuff into Legacy.

Here's a slightly better example to try:

var stringStatus, stringFollowUpDate

stringStatus = GetPropertyOf("plstatus", "Text")
stringFollowUpDate = GetPropertyOf("deNeededDate", "Text")
DisplayValidationMessage("Status: " & stringStatus & vbTab & "FollowUp Date: " & stringFollowUpDate)
If (stringStatus <> "Closed") Then
If (stringFollowUpDate = "") Then
SetProperty "Postable", "False"
ControlDo "deNeededDate", "Focus"
DisplayValidationMessage("We are here....You need to select a Follow Up Date specific to this ticket.")
Else
SetProperty "Postable", "True"
CloseCurrentView False
' WhenClose fires next
End if
End If

I always like to assign variables when doing if statements because you can verify the contents without making multiple calls. The DisplayValidationMessage statement might not be right but the idea was to show you the contents to make sure plstatus and deNeededDate are returning the correct values. I have a feeling plstatus might not be returning "Closed" exactly, if it's even "Closed(space)" it would pass the if check and require a follow-up date.

I broke the if statement down into nested ifs to help visualize the flow. It's unnecessary but I usually do it for debug purposes so I can cross check the various and/or combinations.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Jan 07 9:42 AM
fiogf49gjkf0d
Why call CloseCurrentView at all then? At least not in the validation. I'd just use a variable to hold whether all validation passed or not and then call CloseCurrentView only if that variable says it is ok.

ie:
Dim okClose As Boolean

okclose = True

If (SomeVaidationCheckDoesntPass) Then
' do something
okclose = False
End If

If (SomeOtherVaidationCheckDoesntPass) Then
' do something
okclose = False
End If

If okclose Then CloseCurrentView False


I am wondering if you are misunderstanding what CloseCurrentView is for? The parameter of "Cancel" doesn't mean to cancel the closing of the view. It means to close the view with a result of cancel (as if the user clicked the cancel button).

Am I missing what you're after?
[Reply][Quote]
Sarah Peterson
Posts: 37
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Jan 07 9:52 AM
fiogf49gjkf0d
No, I understand....with my initial postings I may have been a bit confused!!! What I need to do is not something that can be done on the validation of the Ticket screen. I was hoping to be able to run my scripts on the OnClose of the Ticket Detail screen. But I don't imagine that there is actually a way to stop the close from happening if it is in the middle of closing...if that makes sense!

Now I am trying to figure out a way to trick the support client into validation. Basically, I don't want the follow-up date validation that I have to have to be ran when a user punches in/punches out, etc. It needs to run only when the user is finished with the Ticket detail screen and is closing out. However, I have discovered that if nothing has changed on the ticket detail screen (after punch in/punch out and the closing of the activity pop up screen and the user does not change anything on the ticket detail) then goes to 'x' out of the ticket detail screen the validation does not fire again because nothing has changed. That is where the problem lies now. Somehow I need to make this script run ONLY when the user is about to close out of the screen not when the user punches in/punches out.

I know this probably doesn't make a lot of sense as I have tried to explain it as best as I can. Let me know if you need more clarification. I think the whole thing would be easier if it wasn't legacy code/forms, etc.!!! Oh well....
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: Legacy Ticket ValidationYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Jan 07 1:17 PM
fiogf49gjkf0d
In 6.2 the only events for a Legacy form are:
WhenAfterPost
WhenChange
WhenClose
WhenOpen
WhenValidate

Typically the order is WhenOpen, WhenChange, Form is shown to viewer, Modify controls, Click OK, WhenValidate, WhenAfterPost, WhenClose.

Clicking the X is equivalent to clicking the Cancel button. This is expected SLX behavior. The way you trap this is OnCloseQuery. OnCloseQuery's description in the property pane is this: Occurs when the form is about to close. Return FALSE from the event handler to prevent the view from closing. Unfortunately there is no OnCloseQuery equivalent in Legacy so there's no way of trapping when users click the X.

Regarding validation firing for the Punch In/Out screen, move the code to the Ticket's WhenValidate event. WhenValidate will fire when users click OK on the ticket screen. WhenValidate is directly related to pressing the OK button on the form it's tied to.

If you need the punch in/out screen validated when you press the OK button on the ticket screen then that will require a bit of work. That's typically something I don't do because if a child form handles it's own validation, there's no point in a parent form playing babysitter. It looks nice on paper but adds no real benefit.
[Reply][Quote]
 Page 1 of 1 
  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!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 6:34:30 AM