Make functions/event in CU 1535 External instead of Local
Hello Team,
I need help getting access to the following functions/events in Codeunit 1535 Approvals Mgmt.:
LOCAL [IntegrationEvent] OnPopulateApprovalEntryArgument

LOCAL GetLastSequenceNo

LOCAL CreateApprovalRequestForUser

LOCAL MakeApprovalEntry

Let me know if it's possible to make those functions/event publisher external. Thanks!
Hello Anna,
what are you trying to achieve?
I'm creating a custom approval process for requisition worksheet and I need to create/modify approval entries for workflow user groups.
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.
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?
Hello Microsoft team. When will I be able to see this code released?
Hello @Anna-Gudimova there are already available now in the delevoper preview. They will be in the main product with the April Release
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;
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;
[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 .
Hello,
Below is the error, seems something is wrong. Have you tested it ?


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
Hello,
Am using Dynamics 365 onpremise. What can i do ?
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;
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 ?

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.
Am using D365 on premise.
Any short cut for now ?
Add you custom values on Approval Entry Table
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**_
The email is generated by report 1320 Notification Email take a look
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,