2023 R2: Workaround for the ShowContent() symbols not disappearing on context change anymore

Hi all,

We're currently testing the new System Platform 2023 R2, and found out symbols that have been displayed with a ShowContent() do not disappear anymore when the context changes. Support confirmed to us that this is on purpose and not a bug, even if I'm struggling to understand the point...

The way we've designed our layout, symbols like motor controls are displayed on operator actions with a ShowContent and it doesnt make sense to keep them open when the context changes.
Our idea for a workaround was to have a layout script executed on every context change, that basically goes that way for every pane we want to clear:

dim contentInfo as aaContent.ContentInfo;
contentInfo.PaneName = "NameOfThePane";
contentInfo.ContentType = "App_Device_Faceplate";
HideContent(contentInfo);

The contentType is used to avoid wiping the auto-fill content when the script runs after the autofill has already happened, as only the ShowContent() symboles are using the App_Device_Faceplate content type.

The current issue with this basic script is that it runs without checking if there is matching content in the pane, generating logs when there isnt.

Would anyone have ideas on how to improve that script, or a whole different solution we didnt think of ?
I doubt we'll be the only ones struggling with that new feature, as we've seen others use the same mechanism.

Thanks

Parents
  • Hello Quentin, 
    My immediate ideas

    1) Maintain the list of content names and their panes (which can be challenge with Autofill algorithms)
    2) Would be to add a custom property to symbols being display by ShowContent  (e.g. HideOnContextChange with default false) 
    Then on the same symbol have a datachange script something like that:

    Expression: MyViewApp.Navigation.Current
    Body:

    if HideOnContextChange then
    HideSelf();
    endif;

    Now where you use the ShowContent() you can pass a custom property value to it (below is the additional lines to add 

    Dim cpValues [1] as aaContent.PropertyOverrideValue;
    cpValues[1] = new aaContent.PropertyOverrideValue("HideOnContextChange", "True", true);
    contentInfo.PropertyOverrideValues = cpValues;

    The complete example you can see in the online help for ShowContent()

  • I implemented that idea on a test symbol and found one issue: the datachange script runs when the symbol opens (I guess nothing => current context is technically a data change) which hides the symbol instantly.

    To counter that, I've added another custom property ContextOnOpening to the symbol
    It's then filled by the "On Opening" script with a simple

    ContextOnOpening = MyViewApp.Navigation.Current;

    And the datachange script has been modified so that the HideSelf isnt ran if the current context is identical to the context on opening the symbol

    if HideOnContextChange and  MyViewApp.Navigation.Current <> ContextOnOpening then
    HideSelf();
    endif;

    So far it's working perfectly, we'll keep testing but that seems to be the way we'll go when we migrate the production galaxy to 2023 R2

  • Thats great, you could have probaby handle it with
    if HideOnContextChange AND MyViewApp.Navigation.Current<>"" then
    HideSelf();
    endif;

Reply Children