How do you know if you’re in display or change mode?

Though there are usually ways around this, I often need to add additional fields to panels – then I need to determine if we are in display mode vs. change so I can prevent the user from making any changes.

In the past, I’d look at a another control on the panel and determine if it was enabled or not and use that to enable/disable my control. It’s pretty crude and I’ve never really liked it.

In the 10.3.1 H5 Script Developers Guide I noticed this little gem

And thought wahoo! H5 supports it, and at that point the information was filed away in the back of my brain for when I was developing H5 scripts.

Roll on some months and I have several controls to be added to some existing panels within Smart Office. In the back of my mind something stirs…I think, hmmm, H5, now that is going to be using the XML that is returned for each panel…so I thought I’d take a look at the data which Smart Office gets from the MUA (hold down Shift, right click on the Panel and you will get the debug menu – select Show Response XML) and noticed a new attribute on the Panel element!

And it dutifully changes when we go between change and display modes

We now have a non-crude method of determining whether or not the user did a change or a display. I can parse the XML that gets returned to Smart Office for this field and determine our mode (controller.Response.RawContent) – okay, that is still pretty crude, but it is definitive.

I thought I’d do some investigation to see if we had a new property on the PanelState object within Smart Office. I used Object Browse within Smart Office and was disappointed when I didn’t see anything new – but shrugged it off. It’s no secret that ISO is pretty mature and isn’t getting the love it used to.

Today I suddenly twigged that my reference assemblies were those from the original 10.2.1 SDK <rolls eyes>. I grabbed a different tool, grabbed a new MForms.dll and had a look. And what did I see? The Mode property.

A few second later, I had a script to test it with and it worked 🙂

The MUA will probably need to be at least 10.3.1, ISO that I tested with was 10.2.1.265, though I suspect earlier builds will have the property (210 doesn’t).

This entry was posted in Development, M3 / MoveX. Bookmark the permalink.

3 Responses to How do you know if you’re in display or change mode?

  1. Justin says:

    This doesn’t seem to work for me in 10.2.1. Mode is empty. 😦

    • potatoit says:

      Hi Justin,

      the information is fed from the M3 UI Adapter. Patch that to the current version and you should see the field populated.

      Cheers,
      Scott

  2. Justin says:

    Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s