Codeunit 533 IC New Notification JR
src/Layers/W1/BaseApp/Finance/Intercompany/DataExchange/ICNewNotificationJR.Codeunit.al76 lines, Copyright (c) Microsoft Corporation. MIT
// ------------------------------------------------------------------------------------------------// Copyright (c) Microsoft Corporation. All rights reserved.// Licensed under the MIT License. See License.txt in the project root for license information.// ------------------------------------------------------------------------------------------------namespace Microsoft.Intercompany.DataExchange;using Microsoft.Intercompany.GLAccount;using Microsoft.Intercompany.Partner;using System.Telemetry;/// <summary>/// Job queue runner for creating new intercompany notifications and managing outgoing notification queue./// Handles automatic notification generation and processing for intercompany data exchange operations./// </summary>codeunit 533 "IC New Notification JR"{ Permissions = tabledata "IC Outgoing Notification" = m, tabledata "IC API Log" = rimd; trigger OnRun() var ICOutgoingNotification: Record "IC Outgoing Notification"; ICAPILogContext: Codeunit "IC API Log Context"; begin ICAPILogContext.Initialize(); ICOutgoingNotification.SetFilter(Status, '=%1|=%2', ICOutgoingNotification.Status::Created, ICOutgoingNotification.Status::Failed); if not ICOutgoingNotification.FindSet() then begin ICAPILogContext.Finalize(); exit; end; repeat SendNotification(ICOutgoingNotification); until ICOutgoingNotification.Next() = 0; ICAPILogContext.Finalize(); end; local procedure SendNotification(var ICOutgoingNotification: Record "IC Outgoing Notification") var ICPartner: Record "IC Partner"; TempICIncomingNotification: Record "IC Incoming Notification" temporary; ICDataExchangeAPI: Codeunit "IC Data Exchange API"; CrossIntercompanyConnector: Codeunit "CrossIntercompany Connector"; FeatureTelemetry: Codeunit "Feature Telemetry"; ICMapping: Codeunit "IC Mapping"; ContentJsonText: Text; begin ICPartner.Get(ICOutgoingNotification."Target IC Partner Code"); TempICIncomingNotification."Operation ID" := ICOutgoingNotification."Operation ID"; TempICIncomingNotification."Source IC Partner Code" := ICOutgoingNotification."Source IC Partner Code"; TempICIncomingNotification."Target IC Partner Code" := ICOutgoingNotification."Target IC Partner Code"; TempICIncomingNotification."Notified DateTime" := ICOutgoingNotification."Notified DateTime"; ICDataExchangeAPI.CreateJsonContentFromICIncomingNotification(TempICIncomingNotification, ContentJsonText); if CrossIntercompanyConnector.SubmitRecordsToICPartnerFromEntityName(ICPartner, ContentJsonText, 'intercompanyIncomingNotification', 'id', TempICIncomingNotification."Operation ID") then begin FeatureTelemetry.LogUsage('0000MV7', ICMapping.GetFeatureTelemetryName(), NewNotificationEventNameTok); ICOutgoingNotification.Status := ICOutgoingNotification.Status::Notified; ICOutgoingNotification."Notified DateTime" := CurrentDateTime(); ICOutgoingNotification.Modify(); end else begin FeatureTelemetry.LogError('0000MV6', ICMapping.GetFeatureTelemetryName(), NewNotificationEventNameTok, GetLastErrorText(), GetLastErrorCallStack()); ICOutgoingNotification.Status := ICOutgoingNotification.Status::Failed; ICOutgoingNotification.SetErrorMessage(GetLastErrorText()); ICOutgoingNotification.Modify(); Commit(); Error(GetLastErrorText()); end; end; var NewNotificationEventNameTok: Label 'IC Crossenvironment New Notification', Locked = true;}