cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with events

Former Member
0 Kudos

Hello

Forgive me if this is too simple or too obvious but I`m complete beginner and here is my probelm -

I`am trying to modify a matrix after it has been created. Something as simple as adding rows programmatically.

I tried Form Load and Form Activate events but it gave me some errors. Basically it seems that there is lag between creating

form for the first time and populating it with items. Funny thing is that it works second time Form Activate event fires.

On first occurence of this event it complains with "Invalid item..." message. That item is my matrix object. Second occurence and

bing, it works. What am I missing? What fundamental I don`t know about events?

Thanks in advance

Kamil

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Mark but I already set before property to false. Still it does not work. In case of Form Activate event it does not work the

first time it is fired in my form`s lifetime. Then I click on, let`s say, main menu, then go back to my form and this time it works.

The error message I get is -

EXCEPTION: Form__CTPRPL.OnAfterFormActivate raised

Item Invalid Item [66000-3]. Form Unique Id:'CT_PRPL_0' Item

Unique Id: 'mtx_0'

Here is the code fragment in question


[B1Listener(BoEventTypes.et_FORM_ACTIVATE, false)]
        public virtual void OnAfterFormActivate(ItemEvent pVal)
        {
                Form form = B1Connections.theAppl.Forms.Item(pVal.FormUID);
                Item item = form.Items.Item("mtx_0");
                Matrix matrix = (Matrix)item.Specific;
                matrix.AddRow(20, 0);
            
            // ADD YOUR ACTION CODE HERE ...
        }

Thanks

Kamil

Former Member
0 Kudos

OK, never mind.

While I still do not know why it works the way it does my problem has been solved in some other way.

Thanks

Kamil

Former Member
0 Kudos

Hi Kamil,

Each event is fired twice. Once before B1 handles it, and once after. This gives you the opportunity to use the BubbleEvent variable to tell B1 to ignore an event. Use pVal.Before_Action to have your code run after SAP has handled the event. I.E Once it has created your form items.