I'm not sure if this will be possible in Whenchange section.
But I'd try Me.Properties("myProperty").UserChange = False
I'm not sure if UserChange setter is public.
Did you try to just set Enabled formula to be depending on result of other property?
I.e. There are 2 properties PropA and PropB And I want to have PropA disabled when PropB = "BBB" so I'd put in PropA userinterface: Result = Me.PropB <> "BBB"
This will cause that when this property gets value "BBB" PropA will be disabled automatically, without using whenchanged event.
If you'd explain a bit more what exactly would you like to achieve, maybe I'll be able to propose something else.
Thank you for your reply Adam,
The code: Me.Properties("myProperty").UserChange = False works great, so the question is answered. But the problem I thought this answer would solve it is not solved.
Here is the case:
I do have properties A and B
when the user changes A, I want B to be A+2
but when the user changes B, I want A to be B-1
I used the whenchanged tool in rulestream, but it causes infinite loop. For instance.
if the user changes A to 10, then B would be 12. (But rulestream does not stop here, Because B is changed, A would be B-1 which is 11, and Because A is changed to 11, B would be 13.....) I want to stop at the first stage. When the user changes A to 10, then B would be 12 and the process would stop there.
Hmm.. Tricky case. It looks like a circular reference (A refers to B and B refers to A).
What if you try this way: Besides your properties A and B create 2 properties tempA and tempB. In A and B whenchanged set values of tempA and tempB(don't have to be user visible or enabled, but of the same types as A and B) and also revert the other property to calc value.
So it would be:
Formula: Result = me.tempB-1
WhenChanged: me.Properties("tempA").SetInputValue(value, true) me.Properties("B").RevertToCalc()
Formula: Result = me.tempA+2
WhenChanged: me.Properties("tempB").SetInputValue(value, true) me.Properties("A").RevertToCalc()
It's a nasty way but do not have any strict circular references so shuld work. There might be also problems with UI refreshing, but I hope not.
In WhenChanged you can add also check if oldValue IsNot Nothing to prevent triggering whenchanged event when lineitem is opened.
Thanks Adam, that was very helpful.
I have one more question, does Rulestream's "When changed" tool know if the change is manual or programatic. I want to trigger an action when a property is changed, but only if it is manual.
As I know 'When changed' formula is fired every time property is called in runtime.
Whenever it's initialisation, manual overrides, dependency on another property or change done by function from custom.vb.
Didn't test but you can try to use Me.Properties('"X").ValueSource to create condition.
Please find below types of ValueSource:
|SOURCE_CALC||1||Value was calculated via a formula|
|SOURCE_DB||2||Value set by a DB Constraint|
|SOURCE_DBUSER||5||User selected the Value from a DB query?|
|SOURCE_INIT||4||Value Set only once, at Init-time, by formula|
|SOURCE_PART||3||Value is PartNumber driven|
|SOURCE_USER||0||Value set by the User|
Again tricky case (as in general all with WhenChanged. It seems a good practice to design the rules in the way that NO WHENCHANGED is used).
Probably you can use ValueSource as indicated by @RafalLaciak
But it might in some cases give you false result (i.e. if you're using SetInputValue method probably value source will show you that it was manually changed).
Other solution is to add a flag(boolean property) that will be changed by code only (or manual action only) that would allow you to recognize if last change was manual or by code.
But as stated above - if you can redesign the rules to not use WhenChanged - it'll probably be the best.