Coming soon: Your brand new Help Center & Community! Get a sneak-peek here

The Fields with userdefined List by OnCurrentXXXFieldChanged changed not immediately

Hi,

in Scripts to SO 8.4 R06, if changed fields is a user-defined list, and to changing list is also a a user-defined list with a messagebox, then this field changed not immediately on same site also after Save. Example:

Sub OnCurrentContactFieldChanged (fieldname)

    if StrComp(fieldName, "udcontactsmall.long03", vbTextCompare) = 0 then

        currentcontact.Udef.ByProgId("SuperOffice:15").Value = 0

        somessagebox "some necessary message..."

    end if 

End Sub

Here the udcontactsmall.long03 is the same field with user-defined list to currentcontact.Udef.ByProgId("SuperOffice:15").

This field will be not changed on the same site although after clicked the save button. It will be changed only after I change site or tabs back, or click Button Edit.

This Isses happens only in SO 8. the same Scripts works in SO 7.1 fine.

Could someone check this.

Thanks!

RE: The Fields with userdefined List by OnCurrentXXXFieldChanged changed not immediately

Hi Jianchun,
Things change I am afraid. 7.1 is a long time ago.
All our dropdown lists are now using our MDO List Widget.
It has a.o. 1 important guard: When the ItemSelected is broadcasted, it cannot programatically be set to another value.
It is conseptually still busy and the SetId call will simply return.
The underlying Set method in the model can handle this (for this particular use case) and guards only against setting it to the same value so we prevent a never ending-roundtrip. Someone, somewherere has to!

I think that what you are trying to achieve is another example of the poor-man's sentry plug-in.
Your UDef list should remain stuck to (No Selection) or should not be changed by this user.
I suspect the Value=0 is for the sake of this example.

The invocation of a dialog is this event complicates things further by generating a Loose Focus event which the UDef View will use yet again to update its model and broadcast.

The fact that this worked in 7.1 is merely luck. Over the years we have had to deal with increasing number of re-entrancy issues causing either never-ending loops or crashing the system. So we guard against this where necessary.

I am not sure if there is a good enough work-around for this use case. You could perhaps try and exploit the OnCurrentContactBeforeSave message.

Conrad

Af: Conrad Weyns 13. mar 2019

RE: The Fields with userdefined List by OnCurrentXXXFieldChanged changed not immediately

Hi Conrad,

Thanks for your feedbacks! I do understand that selected list item should not be set by Scripts since more runtime requied.

I use till now MDO List for Standard field, like currentsale.Probability = GetListItem(82, 7), but in this case it’s about UDF with Udlist.

The Scripts in Example I have just simpleized, we have more case to verify User selected item from udlist with more Conditions, for example certain items of UDF can be selected by user only for certain Country! If not, then  

currentcontact.Udef.ByProgId("SuperOffice:15").Value = 0 for no Selection or = initial Value by open Contact panel, This scripts in example works fine if I remove SOMesagebox. It would be better to trigger Message by FieldChanged, now it is no possible as you explained, then I set it in beforesave-events to work around. I have to check all scripts by Upgrading from SO 7 to 8 and explained to our end user what is changed and what is not as usual in SO 7.

Thanks a lot!

Af: Jianchun You 14. mar 2019