Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, November 27, 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 - SalesLogix Scripting & Customization
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.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: onChange Issue
Ben
Posts: 26
 
onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 11 Jan 07 4:09 PM
fiogf49gjkf0d
Hi guys,

I am having a situation with the onChange event on a picklist. When users change the value of the picklist, it fires a function which interrogates the value of the picklist. If certain criteria is met, it will check a few other controls on the form and then either continue on its merry way, or stop the user and prompt them to change a few things - typical form validation stuff. If it fails to validate, I change the value of the picklist back to its previous value and prompt the user. The problem is this: when the user corrects the form, and attempts to change the value in the picklist again, the event is not firing. It is as if it doesn't know the value has changed despite the fact I can see that the value in the picklist has reverted to its original value. I guess it has issue with the fact that I am changing the picklist value via the script, and not some mouse interaction with the control.

I have tried posting the form after reverting back to the original value, as well as even refreshing the whole main view in hopes that it would 'reset' the control. I've thought about using onEnter and onExit to simulate an onChange event but there are other issues surrounding onExit.

Any help would be greatly appreciated. Thanks!
[Reply][Quote]
Rick Smith
Posts: 96
 
Re: onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 07 8:54 AM
fiogf49gjkf0d
Consider using a boolean variable at the module level to indicate if the form is being validated.
[Reply][Quote]
Ben
Posts: 26
 
Re: onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 07 9:13 AM
fiogf49gjkf0d
Sorry, Rick. I must not have been clear in my explanation of the problem. There isn't an issue of me detecting when the form is being validated, the problem is the onChange isn't firing. I will try to explain in more detail.

Actions:
- user changes picklist from Option 1 to Option 2
- onChange is triggered firing off a validation()
- validation() prompts the user to correct another control on the form
- validation() changes the picklist value from Option 2 back to Option 1 - on the form, you can visibly see that Option 1 is now selected
- validation() completes is processing and exits
- user corrects the control that failed validation
- user changes pick list from Option 1 to Option 2
- nothing happens; validation() is never fired. <--- problem

At this point I can change the picklist back to Option 1, then back to Option 2 and the onChange fires once again. But the problem is that it doesn't realize the pick list value has changed after that value is modified via the validation().

I hope that made more sense - I find it difficult to convey technical issues via forums.

Thanks.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 07 9:54 AM
fiogf49gjkf0d
Well........

1. Make the Picklist control READONLY....it you truly want picklist values, no sense allowing them to type it in.

2. OnChange events scare me......they mean potentially some form changes (if the picklist value changes between records/forms then it will fire!).....and every Key Stroke of data entry (if you don't have it readonly, see 1).

3. We use OnPopupReturn for DateEdit, LookupEdit, Picklist controls.....much more positive control of the user events.

If you need to know the old value.....DO NOT ADD A CONTROL. Add a Form Global Variable.
DIM OLD_VALUE

On the Change of the form
OLD_VALUE = "" & controltotrack.TEXT
END SUB
On the popup return of the control
IF OLD_VALUE = controltotrack.TEXT (or Sender.TEXT) THEN
perform magic
OLD_VALUE = OLD_VALUE = "" & controltotrack.TEXT
END IF
END SUB

Alternatively, you can wait until Form Validation time to reset the old Value......and then do your IF test and perform magic stuff at validation time..

RJ Samp

[Reply][Quote]
Ben
Posts: 26
 
Re: onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 07 10:09 AM
fiogf49gjkf0d
Hey RJ, thanks for the reply.

1. The PL is read only - users cannot type in the field, thus solving issue 2 as well.
3. This sounds like it could solve my problem - since it removes the issue of old vs new value.

As for knowing the old value, I don't really care what value they had in the PL before, because it has to be set to a specific option after validation failure. But, if I did, I would of course use a variable, not a control.

Thanks for the hint on OnPopupReturn! I'll give that a try now.

edit: gave it a try - works like a charm! Thanks again, RJ.
[Reply][Quote]
Jeremy Brayton
Posts: 491
Top 10 forum poster: 491 posts
 
Re: onChange IssueYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 12 Jan 07 12:22 PM
fiogf49gjkf0d
There are times when OnChange is welcome and even in situations where you can edit the .Text field manually, it's not entirely difficult to let your code play nicely in this scenario. I will admit that there is a sort of logic involved that keeps you thinking, so adhering to something that works 100% of the time does have added value.

I've always used OnChange and have rarely had a serious problem with the behavior. I'm sure there'll be that one case where I'll need something different, so thanks for the info.
[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/27/2024 12:34:52 AM