ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Request-For-External] Codeunit 80 "Sales-Post" - Procedure from Internal to Global

Open MH1612 opened this issue 2 years ago • 9 comments

Describe the request

Hello, we need the following currently local procedure to be set to global. Can you please check this? Thank you!

procedure PostUpdateReturnReceiptLine()
local procedure PostUpdateInvoiceLine(var SalesHeader: Record "Sales Header")

Additional context

Post a Invoice with Return Receipts Internal work item: AB#523913

MH1612 avatar Mar 27 '24 06:03 MH1612

@MH1612 both the methods seem to depend on one or more global variables to be set, making those methods as public increases the risk of those methods failing or returning undesired results. Can you please explain the use case for better understanding?

ChethanT avatar May 01 '24 10:05 ChethanT

Hi,

I will answer for my colleague. We have build a process to Post an Invoice connected to a Return Receipt (and also a Credit Memo connected to Sales Shipments). For that it is neccessarry to the call to procedure out of COD80-Events (out of existing Events where the sender is also accessable)

In my opinion the procedure doesn't use global variables (only text labels). The similar procedures in COD90 (PostUpdateInvoiceLine, PostUpdateCreditMemoLine) are already set to global.

SKeiler avatar May 02 '24 09:05 SKeiler

Both these methods use global variable TempSalesLineGlobal. How do you plan to set it up before calling this method?

local procedure PostUpdateReturnReceiptLine() var SalesOrderLine: Record "Sales Line"; ReturnRcptLine: Record "Return Receipt Line"; TempSalesLine: Record "Sales Line" temporary; IsHandled: Boolean; begin IsHandled := false; OnBeforePostUpdateReturnReceiptLine(TempSalesLineGlobal, IsHandled); if IsHandled then exit; .... .... end; local procedure PostUpdateInvoiceLine(var SalesHeader: Record "Sales Header") var SalesOrderLine: Record "Sales Line"; SalesShptLine: Record "Sales Shipment Line"; TempSalesLine: Record "Sales Line" temporary; TempSalesOrderHeader: Record "Sales Header" temporary; CRMSalesDocumentPostingMgt: Codeunit "CRM Sales Document Posting Mgt"; IsHandled: Boolean; begin IsHandled := false; OnBeforePostUpdateInvoiceLine(TempSalesLineGlobal, IsHandled); if IsHandled then exit; ... ... end;

ChethanT avatar May 15 '24 11:05 ChethanT

Hi,

we want to call the functions in context of codeunit 80 out of an Event Subscriber with has the Include-Sender-Property set (so the global variables are also available). The global variable is also only used in the Event Publisher, not in the "normal" procedure source code.

SKeiler avatar May 16 '24 07:05 SKeiler

@SKeiler, codeunit 80 does not seem to have any IntegrationEvent where both 'IncludeSender' and 'GlobalVarAccess' is set to true. Is there a different ask for that?

ChethanT avatar May 22 '24 07:05 ChethanT

Hi @ChethanT: It's enough if IncludeSender is true. Then you could call the procedure out of an EventSubscriber for the Sender-Parameter and the existing global variables are existing in the Instance of the Sales-Post-Codeunit.

SKeiler avatar May 22 '24 07:05 SKeiler

Hi @ChethanT: It's enough if IncludeSender is true. Then you could call the procedure out of an EventSubscriber for the Sender-Parameter and the existing global variables are existing in the Instance of the Sales-Post-Codeunit.

Ahh, thats what you mean. Thanks for the clarification

ChethanT avatar May 22 '24 08:05 ChethanT

Processed for Wave 2 2024.

JesperSchulz avatar Jun 18 '24 10:06 JesperSchulz

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 19857.

JesperSchulz avatar Jun 18 '24 12:06 JesperSchulz