I am making some changes to one of our form customizations and saw that there is a PropertyChanged control event in the wizard. Does this PropertyChanged event function the same way as if I were to write it in Visual Studio?
I have code that I want to run when a certain drop down field changes from null to one of 3 options.
The current plan is to write it as a switch case that will run 1 of 3 code snippets based on the value that the field changes to.
Is there some good ol’ EpiMagic that will handle this for me? Or is it best to just write it with my own custom events in tandem with propertychanged in the script editor?
I don’t know anything about how it would be in visual studio, but couldn’t you just tie your code to a field change event? Basically, when a user changes a value you want some code to run right?
Yes but only when it goes from null to a certain value to run code. There will be 3 different cases that will only need to be run once utilizing different code snippets.
The issue I was running into was anytime the field was changed it would run the code. This is being used in our quote process and sometime users will change the field from quote to order and it would run the code again and mess up pricing in case the user made some changes to the quote pricing per line before converting it into a sales order.
Well, my coding isn’t great, and I’m having trouble finding exactly what I want, but, I think that if you put an event on before field change that you can check the current value and the proposed value to get a way to queue the code to run or not. I don’t have a good playground to test this on right now though.
Are you checking something that is in a current data view? (that would make it easier I think)
Dumb idea: A hacky way to do it would be to set a variable on click of the field to the current value. Then you have something to compare it to. Then when it changes, you do the on change and only run the code if that that field when from null to something. So you would have two different events, but that would be able to give you a before and after in order to check on whether to do something.
Also, BPM’s have better abilities to filter changes from something to something else, (like null to any), but it would generally only run on save. So maybe not what you are looking for?
I had looked at the BPM functionality but want to see if I can exhaust my current options before going down that path.
I might just go back to the drawing board as this is probably going to have to take some more insight from me into BPMs and coding those as opposed to doing it directly in the script editor.
FWIW, I think the BPM’s are a lot easier to do than the script editor in the client. There are a lot more helper type things, but I’m not a coder first, so that’s probably why it’s easier for me. If you already have the code, you can also drop in the code into a custom code block in the BPM, but there will probably need to be some tweaks done to it.
Assuming the Combo in question is Epi-Bound, then yes. You can jsut do a before or after field change event on the correct epiDataView\field.
It is the preferred method over control events. See @josecgomez, arent you proud? Well moderately speaking…
I’ll take the win… (however small)
That’s good to know. Still a lot of little things I need to learn with how to make the system be more efficient.
Edit: Looking back at what I currently have I think I did try and do it after field change as I have existing code with 4 cases and I wasn’t able to get my code to run. I think I may have seen what I did wrong though…