ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

Add "Update Event" for Loop-function on worksheet pages (e.g. page 256 Payment journal)

Open RedFoxUA opened this issue 8 years ago • 12 comments

we have some worksheet pages where we have field "CurrentJnlBatchName" (e.g. page 256 Payment journal)

this page has trigger CurrentJnlBatchName - OnLookup(VAR Text : Text) : Boolean usually and this trigger does not do validation, but just set filters in the GenJnlManagement CU (it is CU 230 GenJnlManagement).

The issue - when user updates Batch name from LookUp page it is not possible to catch this moment correctly and do some visual update (e.g. disable icons).

P.S. it is good to have variable CurrentJnlBatchName accessible from AL (VSC) and have possibility to do something like; GenJnlBatch.GET(GenJnlLine.GETRANGEMAX("Journal Template Name"),CurrentJnlBatchName) instead of ..

RedFoxUA avatar Nov 14 '18 20:11 RedFoxUA

Would you like an event OnAfterCurrentJnlBatchNameValidate? Or before? With which parameters?

JesperSchulz avatar Nov 22 '18 10:11 JesperSchulz

I need Business Event like OnAfterCurrentJnlBatchNameLookUp - because I can catch the moment (without FILTERGROUP changing) when User updates value (if you see source code - when a user does LookUp, the source code does not do VALIDATE). And to do it I need to have Old and New value (to understand real update) because it is not a part of the Rec.

it is good to have Business Event like OnBeforeCurrentJnlBatchNameValidate & like OnAfterCurrentJnlBatchNameValidate also, but it is not so crucial for me.

RedFoxUA avatar Nov 22 '18 19:11 RedFoxUA

any news?

RedFoxUA avatar Dec 13 '18 20:12 RedFoxUA

Sorry about the late reply, but I had to go hunt for answers first. I'm sorry to reply, that we cannot implement your suggestion right now. We do not support OnLookup events at the moment, as they come with various challenges we need to be able to handle before we can get to this. Could you work around your issue by using the events in codeunit 230 - "GenJnlManagement"? Maybe you can use one of those:

LOCAL [IntegrationEvent] OnAfterSetName(VAR GenJournalLine : Record "Gen. Journal Line";CurrentJnlBatchName : Code[10])

LOCAL [IntegrationEvent] OnBeforeLookupName(VAR GenJnlBatch : Record "Gen. Journal Batch")

JesperSchulz avatar Dec 20 '18 10:12 JesperSchulz

Hi Jesper Schulz-Wedde. Thank you for your answer. You advised the solution, right? Could you explain to me how to receive "information" is the Batch name was changed or not from "OnBeforeLookupName.."?

about "LOCAL [IntegrationEvent] OnAfterSetName(VAR GenJournalLine : Record "Gen. Journal Line";CurrentJnlBatchName : Code[10])" - I think it is a good idea (based on current code this I have - it is better to use "OnBeforeSetName.."), but based on parameters of function we have function definition: SetName(CurrentJnlBatchName : Code;VAR GenJnlLine : Record "Gen. Journal Line").. again, you have rules and I think, if it should solve the issue - if we have an old value and new.. we can define that Batch was changed.

RedFoxUA avatar Dec 21 '18 19:12 RedFoxUA

Hi RedFoxUA, I'm sorry, but this one keeps passing under my radar - probably because I don't know what to tag it with, which makes it disappear in the masses. I apologize once more. I'm afraid I'm a little lost here, as I don't entirely understand what you are requesting. Do you want us to add events at some place? Could you maybe provide some code for us to follow, like in this example: https://github.com/Microsoft/ALAppExtensions/issues/955. There more specific you are in your request, the easier it is for us to help you.

JesperSchulz avatar Jan 25 '19 13:01 JesperSchulz

In case you'd like us to add parameters to an existing event, we can do that as well, like in this example: https://github.com/Microsoft/ALAppExtensions/issues/949.

JesperSchulz avatar Jan 25 '19 13:01 JesperSchulz

Hi Jesper Schulz-Wedde. Thank you for your answer. I no need to add parameters, but just insert the Event.

The sequence for understanding are:

  • open page 256 Payment journal
  • open code for Control "CurrentJnlBatchName" - OnLookup(VAR Text : Text) You can see code: CurrPage.SAVERECORD; GenJnlManagement.LookupName(CurrentJnlBatchName,Rec); CurrPage.UPDATE(FALSE); This trigger does not do validation for field, right? It is just set filters in the GenJnlManagement CU (it is CU 230 GenJnlManagement) and update page.

Question - how can the Extension understand that the current Batch was changed by User?

P.S. We have 2 possible ways to fix it - by Event (it is good to have 2 Before- and After) or by Extra-field(-s). Is

RedFoxUA avatar Jan 25 '19 16:01 RedFoxUA

It indeed sounds like you need an event here. I will tag your issue with "event request" and have our event experts take a look at your problem! I hope they will be able to provide you with what you need! Thanks for taking the time to explain.

JesperSchulz avatar Jan 29 '19 13:01 JesperSchulz

Thank you. I used another way to catch this change, but with Event, it will be easier.

RedFoxUA avatar Jan 29 '19 13:01 RedFoxUA

Just a brief elaboration of issues with adding an event in the Lookup: The challenge with the LookUp is, that there can only ever be one that handles it - you would not want 5 different windows to pop up one after another, when invoking the lookup ;-) That as such disqualifies normal events, which is why you don't find them as system events. We could try to play with publishers using the handled pattern, but there would still be the risk of multiple subscribers trying to handle it - it's hence not a good solution. A sub-ideal workaround could also be to create a new field on at page extension, while hiding the original implementation. That is not pretty, but would also do the trick. Bottom line is, that we're aware of the challenge, but we don't have a solution yet. It's hence good that you found a work around, as it may take a little time for us to get the right solution :-)

JesperSchulz avatar Jan 31 '19 14:01 JesperSchulz

After some more thought, we've decided to close this issue, as you seem to have found a workaround. We'll continue thinking about a broader fix for this issue, but with the current toolbox, there isn't much we can do. If you are stuck again, please create a new ticket and we'll take it from there. Thank you for your input.

JesperSchulz avatar Feb 14 '19 13:02 JesperSchulz