cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to capture Action_Success event during update

Former Member
0 Kudos

Hi I am using SAP-B1 2004. Using UIAPI, i am trying to do something when an item information in item master is updated.

On update button click i am capturing the Before_Action =True event to do something. If the Item information is successfully updated, i am trying to capture Action_Success = True event to do something.

The problem i am encountering is that, the Action_Success event is not getting fired.

After Before_Action =True , Before_Action =false event is getting fired and after that the item uid value changes from 1 (for update button) to some other value.

Any idea why this is happening? My code is as follows:

If pVal.FormType = 150 And pVal.FormMode = 2 Then

If pVal.ItemUID = "1" And pVal.EventType =

et_ITEM_PRESSED And pVal.Before_Action = True Then

**Do Something***

End If

If pVal.ItemUID = "1" And pVal.EventType =

et_ITEM_PRESSED And pVal.Action_Success = True Then

**Do Something***

End If

If pVal.ItemUID = "1" And pVal.EventType =

et_ITEM_PRESSED And pVal.Action_Success = false Then

**Do Something***

End If

End If

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Florian,

Your reply was quite informative. But i have a slightly different requirement.I will explain my requirement in a

better way here.

Why i am using Action_Success is because i am synchronising the item master data information between B1 and another system. The flow is as follows:

Before item master data is updated in B1 (pVal.Before_Action = True )

1. Start a transaction in another system

2. Update item master data in another system

After item master data is successfully updated in B1

(pVal.Action_Success = True)

1. Commit the transaction in another system

After item master data is NOT successfully updated in B1

(pVal.Action_Success = False)

1. Rollback the transaction in another system

I use the same logic when i am adding a new item in the item master. This works fine. But when i use this logic to update the item information, the Action_Success event is not fired. What happens is that after pVal.Before_Action = True and pVal.Before_Action = False

the value of pVal.ItemUID changes from "1" to some other value(example 240 or 241).

I do not know why this is happening.Am i missing something?

Do you know a better way of achieving this?

Thanks.

Former Member
0 Kudos

I also have to synchronize product master data. But: Why do you send it at BeforeAction=true? That doesn't make sense to me.

That's how I do it:

Before item master data is updated in B1 (pVal.Before_Action = True)

1. check the form if my requirements are met (=validation)

2. if everything okay, return true, else show error, set BubbleEvent

After item master data is successfully updated in B1

(pVal.Action_Success = True)

1. send the product data to the other system, fire and forget. I go like: if my client-side validation passed, the other system will accept the product.

I could imagine: you're doing this step to make shure the product can be created in the other system? Or what is it good for then to send something to another system even there is nothing created yet in SBO?

Florian

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Florian,

You are right. I am doing this to make sure that the item is created in both the systems.

As UIAPI doesnt have transactons, i have to use the transaction of the third party system. That is why i first start transaction in third party, then create item there, after that if the item is also created successfully in B1, i commit the transaction in the third part system otherwise i rollback the transaction.

Thanks and regards,

Former Member
0 Kudos

Just change the second condition from

 If pVal.ItemUID = "1" And pVal.EventType =
et_ITEM_PRESSED And pVal.Action_Success = True Then

to

If pVal.ItemUID = "1" And pVal.EventType =
et_ITEM_PRESSED And pVal.BeforeAction = false Then

and forget ActionSuccess.

If there is an error in between, the "et_ITEM_PRESSED pVal.BeforeAction = false" is not sent. This means, whenever you get the event "et_ITEM_PRESSED pVal.BeforeAction = false", the action actually was successful.

You may want to test it with following proof-snippet:

If pVal.FormType = 150 And pVal.FormMode = fm_UPDATE_MODE Then
    If pVal.ItemUID = "1" And pVal.EventType = _
        et_ITEM_PRESSED And pVal.Before_Action = True Then
        Debug.Print "before"
    End If
    
    If pVal.ItemUID = "1" And pVal.EventType = _
        et_ITEM_PRESSED And pVal.Before_Action = False Then
        Debug.Print "after"
    End If
    
    If pVal.ItemUID = "1" And pVal.EventType = _
        et_ITEM_PRESSED And pVal.Action_Success = True Then
        Debug.Print "success"
    End If
    
    If pVal.ItemUID = "1" And pVal.EventType = _
        et_ITEM_PRESSED And pVal.Action_Success = False Then
        Debug.Print "no success"
    End If
End If

Case 1: Update successful

Output: before, after, no success

Case 1: Update fails

Output: before, no success

Means: forget ActionSuccess, use BeforeAction true/false.

(That's how solved the problem did it when I encountered the same problem.)

Problem is, you're not able to to something if there was an error. But why would you want to? User sees a red error message and tryes again...

Florian

Message was edited by: Florian Zeller