cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding items on system forms with XML

Former Member
0 Kudos

** Moved from Business One forum to B1 SDK, as the question is more relevant here. Original thread: http://scn.sap.com/thread/3386575 **

Is it possible to hide items on system forms using XML with LoadBatchActions()?

I know this is possible using the standard UI API calls, e.g. oForm.Items.Item("394").Visible = false; // or something along those lines

But I'd like to do it in XML as I believe the performance is better, meaning there's less delay when opening the form (it's awfully slow when hiding lots of items in one go). I have the following XML but it doesn't work - I can change the caption of the item by adding this to the <specific> block (so I know I'm on the right lines), but I cannot change the visibility of the item. I've tried changing the frompane and topane attributes to -1 to hide, but that also doesn't work.

<?xml version="1.0" encoding="UTF-16"?>

<Application>

  <forms>

    <action type="update">

      <form FormType="134" uid="">

        <datasources />

        <Menus />

        <items>

          <action type="update">

            <item uid="394" frompane="-1" topane="-1">

              <AutoManagedAttribute>

                <Attribute description="visible" id="1" modeAdd="0" modeFind="0" modeOk="0" modeView="0" />

                <Attribute description="editable" id="2" modeAdd="0" modeFind="0" modeOk="0" modeView="0" />

              </AutoManagedAttribute>

              <specific />

            </item>

          </action>

        </items>

        <DataBrowser/>

      </form>

    </action>

  </forms>

</Application>

Does anyone know if this is possible, and if so how I can change the above XML to make it work?

Cheers.

Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Ted,

Yes it is possible.

This is the xml I use to hide the Tel1 from the BP form.

<?xml version="1.0"?>

<Application>

  <forms>

    <action type="update">

      <form uid="{0}">

        <items>

          <action type="update">

            <item uid="43" visible="0">

              <AutoManagedAttribute/>

            </item>

            <item uid="44" visible="0">

              <AutoManagedAttribute/>

            </item>

          </action>

        </items>

      </form>

    </action>

  </forms>

</Application>

Note that I use the specific uid of the form to identify it. Just adapt it to your needs, but basically to hide use the visible attribute of the item tag (there is also an editable attribute should you need it).

Good luck.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Thank you Pedro, that works - exactly what I wanted. Sometimes the simplest solution works best, and yours is certainly minimal XML compared to what I was trying.

However I have a small problem with this solution. It works absolutely fine for certain fields but for some fields on the BP record, the visibility changes when you cycle through records using the arrow buttons in the toolbar. This specifically happens with the BP Channel Code, Technician and Territory group of fields, and it's annoying as for certain BPs they're invisible (as I want them to be) and for others they reappear. This seems to be consistent among BPs - one BP will always have the same visibility of these fields.

To solve this, I used the from_pane and to_pane attributes of the item instead of using visible. I think SAP must reset the visible attribute to 1 at some point during form mode switching, whereas it doesn't seem to change the pane attributes. Therefore you can set the from_pane and to_pane to something arbitrarily high like 99, and it'll never show the fields, no matter which BP record you're currently browsing. For example:

<item uid="335" from_pane="99" to_pane="99">

    <AutoManagedAttribute />

</item>

pedro_magueija
Active Contributor
0 Kudos

Hi Ted,

Yes it's true, some items do get "reset" by B1. But congrats on finding a solution to your problem and sharing.

Cheers.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Answers (0)