AL icon indicating copy to clipboard operation
AL copied to clipboard

Make functions/event in CU 1535 External instead of Local

Open Anna-Gudimova opened this issue 8 years ago • 22 comments

Hello Team,

I need help getting access to the following functions/events in Codeunit 1535 Approvals Mgmt.:

LOCAL [IntegrationEvent] OnPopulateApprovalEntryArgument image

LOCAL GetLastSequenceNo image

LOCAL CreateApprovalRequestForUser image

LOCAL MakeApprovalEntry image

Let me know if it's possible to make those functions/event publisher external. Thanks!

Anna-Gudimova avatar Sep 05 '18 22:09 Anna-Gudimova

Hello Anna,

what are you trying to achieve?

GiorgosPa avatar Sep 11 '18 09:09 GiorgosPa

I'm creating a custom approval process for requisition worksheet and I need to create/modify approval entries for workflow user groups.

Anna-Gudimova avatar Sep 13 '18 00:09 Anna-Gudimova

We have a project for the client who needs this for their functionality. They are going Live in 2 months, so we need it urgently.

Anna-Gudimova avatar Sep 13 '18 01:09 Anna-Gudimova

We can't make the publisher external. It was a mistake to make the other publishers external. Events should only be raised from one point. Could you go around that or else what are you missing?

GiorgosPa avatar Sep 18 '18 08:09 GiorgosPa

Hello Microsoft team. When will I be able to see this code released?

Anna-Gudimova avatar Nov 22 '18 18:11 Anna-Gudimova

Hello @Anna-Gudimova there are already available now in the delevoper preview. They will be in the main product with the April Release

GiorgosPa avatar Dec 13 '18 14:12 GiorgosPa

Any code samples for OnPopulateApprovalEntryArgument ?

Am doing customer approvals, and i need to add a new document type in approvals table, and also i want to insert document no for my custom table. advice please.

Below code is not now working.

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.", 'OnPopulateApprovalEntryArgument', '', false, false)] procedure PopulateApprovalEntryArgument( RecRef: RecordRef; ApprovalEntryArgument: Record "Approval Entry") var StoreReq: Record "Store Requisition"; begin CASE RecRef.Number of DATABASE::"Store Requisition": begin RecRef.SetTable(StoreReq); ApprovalEntryArgument."Document Type" := StoreReq."Document Type"; ApprovalEntryArgument."Document No." := StoreReq."Requisition No."; ApprovalEntryArgument.Amount := StoreReq."Expected Total Cost"; ApprovalEntryArgument."Currency Code" := StoreReq."Currency Code"; end END end;

dicksonkimeu avatar Dec 16 '18 19:12 dicksonkimeu

The event signature is

LOCAL [IntegrationEvent] OnPopulateApprovalEntryArgument(VAR RecRef : RecordRef;VAR ApprovalEntryArgument : Record "Approval Entry";WorkflowStepInstance : Record "Workflow Step Instance")

Try this code

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.",'OnPopulateApprovalEntryArgument', '', false, false)]
procedure PopulateApprovalEntryArgument(var RecRef: RecordRef;var ApprovalEntryArgument: Record "Approval Entry";WorkflowStepInstance : Record "Workflow Step Instance")
var
  StoreReq: Record "Store Requisition";
begin
  case RecRef.Number of
    DATABASE::"Store Requisition":
    begin
      RecRef.SetTable(StoreReq);
      ApprovalEntryArgument."Document Type" := StoreReq."Document Type";
      ApprovalEntryArgument."Document No." := StoreReq."Requisition No.";
      ApprovalEntryArgument.Amount := StoreReq."Expected Total Cost";
      ApprovalEntryArgument."Currency Code" := StoreReq."Currency Code";
    end;
  end;
end;

GiorgosPa avatar Dec 17 '18 12:12 GiorgosPa

[image: image.png]

On Mon, Dec 17, 2018 at 3:32 PM Georgios Papoutsakis < [email protected]> wrote:

The event signature is LOCAL [IntegrationEvent] OnPopulateApprovalEntryArgument(VAR RecRef : RecordRef;VAR ApprovalEntryArgument : Record "Approval Entry";WorkflowStepInstance : Record "Workflow Step Instance")

Try this code

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.", 'OnPopulateApprovalEntryArgument', '', false, false)] procedure PopulateApprovalEntryArgument( var RecRef: RecordRef; var ApprovalEntryArgument: Record "Approval Entry";WorkflowStepInstance : Record "Workflow Step Instance") var StoreReq: Record "Store Requisition"; begin case RecRef.Number of DATABASE::"Store Requisition": begin RecRef.SetTable(StoreReq); ApprovalEntryArgument."Document Type" := StoreReq."Document Type"; ApprovalEntryArgument."Document No." := StoreReq."Requisition No."; ApprovalEntryArgument.Amount := StoreReq."Expected Total Cost"; ApprovalEntryArgument."Currency Code" := StoreReq."Currency Code"; end end end;

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/AL/issues/3582#issuecomment-447829842, or mute the thread https://github.com/notifications/unsubscribe-auth/AERPlvdTyb1CDPFKsZOK_r6pFHTvprtaks5u5473gaJpZM4WbyDE .

dicksonkimeu avatar Dec 17 '18 12:12 dicksonkimeu

Hello,

Below is the error, seems something is wrong. Have you tested it ?

image

image

muleso avatar Dec 17 '18 12:12 muleso

This is a recent change, it should not have happened on a minor update but it did. The event signature changed from

LOCAL PROCEDURE OnPopulateApprovalEntryArgument@111(VAR RecRef@1000 : RecordRef;VAR ApprovalEntryArgument@1001 : Record 454);

to

LOCAL PROCEDURE OnPopulateApprovalEntryArgument@111(VAR RecRef@1000 : RecordRef;VAR ApprovalEntryArgument@1001 : Record 454;WorkflowStepInstance@1002 : Record 1504);

In both cases the subscriber should use VAR for RecRef and ApprovalEntryArgument. Your tenant has not been updated yet but it should be updated soon

GiorgosPa avatar Dec 17 '18 13:12 GiorgosPa

Hello,

Am using Dynamics 365 onpremise. What can i do ?

dicksonkimeu avatar Dec 17 '18 13:12 dicksonkimeu

Adding var on the subscriber function parameters should fix the issue

[EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.",'OnPopulateApprovalEntryArgument', '', false, false)]
procedure PopulateApprovalEntryArgument(var RecRef: RecordRef;var ApprovalEntryArgument: Record "Approval Entry")
var
StoreReq: Record "Store Requisition";
begin
CASE RecRef.Number of
DATABASE::"Store Requisition":
begin
RecRef.SetTable(StoreReq);
ApprovalEntryArgument."Document Type" := StoreReq."Document Type";
ApprovalEntryArgument."Document No." := StoreReq."Requisition No.";
ApprovalEntryArgument.Amount := StoreReq."Expected Total Cost";
ApprovalEntryArgument."Currency Code" := StoreReq."Currency Code";
end
END
end;

GiorgosPa avatar Dec 17 '18 13:12 GiorgosPa

Hello, that worked. but my issue is to add a document type on the Approval Entry. It picks Quote. How can i add custom Document Types ?

image

dicksonkimeu avatar Dec 17 '18 14:12 dicksonkimeu

Unfortunately the Document Type Option Field on the Approval Entry table is not extensible. We are working on making Document type Options extensible. For now you may only choose one of the following values Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order.

Note that the option value is an integer on the background so you need to align the values of the Document Type option on the Store Requisition table with those on the Document type of the Approval entry table.

GiorgosPa avatar Dec 17 '18 14:12 GiorgosPa

Am using D365 on premise.

Any short cut for now ?

dicksonkimeu avatar Dec 17 '18 14:12 dicksonkimeu

Add you custom values on Approval Entry Table

GiorgosPa avatar Dec 17 '18 14:12 GiorgosPa

Hello,

It has worked thank you, any idea on how i can make the email notifications more descriptive like the ones for purchase orders. Currently, the look like below. Like adding amount, document no etc

_**Store Requisition  requires your approval.

  | Due Date 12/17/18   | Store Requisition Details Created By xx\xxx**_    

dicksonkimeu avatar Dec 17 '18 14:12 dicksonkimeu

The email is generated by report 1320 Notification Email take a look

GiorgosPa avatar Dec 17 '18 15:12 GiorgosPa

Have seen, seems there is a bit of work MS has to do to expose all events we can subscribe to, like for this, we can't edit the email because all functions are local and dependent on objects C/AL identifies,

dicksonkimeu avatar Dec 17 '18 15:12 dicksonkimeu