Setting Interest - not updating view in SO 8

Hi Forum.

In 7.5 we had a script, that prevented users from edit certain interests, by reverting the state of the interest back to its original state. This was done using the Add or Remove command, like in this example:

Set newInterest = CurrentPerson.Interests
newInterests.Add(intId)

As an example, when a user tried to deselect an interest, it would immedially be selected again by the script.

In 8.2 the code also works, but the view isn't refreshed. Only when jumping from one view (eg. information) and back to Interests, the check-boxes gets updated. How can this be?

RE: Setting Interest - not updating view in SO 8

How can this be?

We, or simply I, screwed up! No problem at all...
I will look into it.

Conrad

 

tfs: 58455

Af: Conrad Weyns 26. apr 2018

RE: Setting Interest - not updating view in SO 8

Hi Conrad. Thank you for your answer.

So this will be fixed in an upcomming update?

In my script, I also have a variable (Bool isDialogOpen), who is set when the personcard is shown or hidden. In 7.5 this variable would keep its value (true or false) when pressing 'Shift+f5', even when the personcard is open.

In 8.2 this variable resets to 'false' upon pressing 'Shift+f5'. This screws my code, because whenever a user presses this commando with the personcard open, my code thinks the dialog in hidden. 

How can this be, and is there a way to get around it?

Af: Kasper Rosenlund 26. apr 2018

RE: Setting Interest - not updating view in SO 8

#Conrad: As an addemdum to your post:

Is there a way (through code) to either refresh the 'Interest' view, or to quickly jump between two tabs on the personcard, thus hopefully refreshing the view?

I've tried with Context.Set "superoffice:person.interest", but this only loads an empty interest view on the person card. And I don't know how to jump to other tabs.

Af: Kasper Rosenlund 26. apr 2018

RE: Setting Interest - not updating view in SO 8

#Conrad: As an addemdum to your post:

Is there a way (through code) to either refresh the 'Interest' view, or to quickly jump between two tabs on the personcard, thus hopefully refreshing the view?

I've tried with Context.Set "superoffice:person.interest", but this only loads an empty interest view on the person card. And I don't know how to jump to other tabs.

Af: Kasper Rosenlund 26. apr 2018

RE: Setting Interest - not updating view in SO 8

Hi Kasper,
There are several issues here.
- 7.5 is a long time ago. Expect breaking changes.
- The Person Dialog is dying real soon now, in our upcoming 8.3 release. It is now a full fledged Panel as Contact, Project etc.
- Shift-F5, the sledgehammer, that in my honest opinion should never have been published to the outside, does not garantee anything. It never has and I don't believe it ever will. It is impossible to make 100% and let's be honest, it is now allmost the same as a restart. Better to restart, then at least you'll know the internal state will be good to start with. We have wasted too much time on that one.
Try: Application.RequestRestart( "blahblablah" ) ....

There is now a new F5 (not Shift-F5) that I call for shallow-flush. This attemps to reload all data only and refresh the views, not also recreate a undefined number of heavy gui components. It is available via soprotocol and the COM Application object: Application.PostShallowFlushEvent.

We are committed to maintain this one a 100%. Typically we now use it ourself after a Merge/Move and a BulkUpdate job.

However, it makes no sense in a FieldChanged event to reset an interest and use PostShallowFlushEvent. What do you expect us to do with dirty models? Save or Cancel? Surely the user should decide!

- Shift-F5 and F5 will also reload all scripts. Traditionaly, the shift-f5 is a developer's utility. You make a change to a script, hit shift-f5 or F5, and retest your script.
However, since you can reload all scripts from the Script Utils menu and our own code (Merge/Move and the new BulkUpdate a.o.) is now relying on the shallow-flush, I can see that may be reloading all scripts should not be part of this sequence. I will have a new look at that.

- There is a new and garanteed way of keeping track of Views being shown/hidden. Introduced years ago now but I can't remember in what version.
Use the Script Event viewer to watch the view messages like these:

4: 04:54:57:740 OnViewHidden (1) [VT_I4] 536556, [VT_BSTR] MainWindow.ContactPanel.ContactCardInterestsView
5: 04:55:03:948 OnViewPreShow (1) [VT_I4] 2887238, [VT_BSTR] MainWindow.AppointmentDialog
6: 04:55:03:953 OnViewPreShow (1) [VT_I4] 396204, [VT_BSTR] MainWindow.AppointmentDialog.AppointmentDialogDescriptionView
7: 04:55:03:990 OnPersonFieldsChanged (1) [VT_BSTR] SetContactId, [VT_UI4]0, [VT_BSTR] CONTACT_ID, [VT_INT]1537
8: 04:55:04:330 OnViewShown (1) [VT_I4] 2887238, [VT_BSTR] MainWindow.AppointmentDialog
9: 04:55:04:334 OnViewShown (1) [VT_I4] 396204, [VT_BSTR] MainWindow.AppointmentDialog.AppointmentDialogDescriptionView

Any view that has a registered NamedControlText will automatically broadcast.
You can print out a list of all registered names from Application.NamedControlTexts.

- The refresh issue you are having, I will look into and try and fix for the upcoming 8.3 release. Hooking on to scripting event was never meant to be used as a sort of Sentry. With Event hooking, we generally have lots of issues guarding againts never ending re-entrancy. So in this particular case, the click on an interest checkbox was guarded aganst round-tripping in the view as a result of an incomming model change. I will re-open that and avoid hell somehow differently. We do not realy have a good and user friendly mechanism for what you want to achieve: disabling the edit mode of individual interests, once set and saved (presumably by someone else?).

I have no quick fix/work-around for you.

Conrad

Af: Conrad Weyns 27. apr 2018

RE: Setting Interest - not updating view in SO 8

Message deleted...
/conrad

Af: Conrad Weyns 27. apr 2018

RE: Setting Interest - not updating view in SO 8

Fixed in upcoming 8.3.
/conrad

To whom it may concern.
I.m.h.o. this was not a bug. It is a use that the event system is not designed for.
I have now catered for this particular use case but do not expect this to work for any fields.

 

Af: Conrad Weyns 28. apr 2018

RE: Setting Interest - not updating view in SO 8

Hi Conrad. 

Thank you for your long and detailed answer.-

Ill take a deeper look at ýour suggestions, and try to wrap my head around the limitations of the system. Whether or not its intended or a bug/unwanted behavior.

I'm relatively new to developing solutions to SuperOffice, so often I don't have the full overview over what should be achievable :). 

Af: Kasper Rosenlund 30. apr 2018