-
Notifications
You must be signed in to change notification settings - Fork 693
Open
Labels
SCMGitHub request for SCM areaGitHub request for SCM areaevent-requestRequest for adding an eventRequest for adding an event
Description
Why do you need this change?
When the user selects the action TransferOldTexts/ 'Transfer texts' on page 837 "Reminder Terms List" the existing reminder texts are copied to the new communication tables. The values of the fields added via table extension to table 294 "Reminder Text" are not transferred.
We need an event to transfer the values of the fields added via table extension to table 294 "Reminder Text" to table 504 "Reminder Attachment Text Line".
Describe the request
We would like to request an event to the internal procedure TransferReminderText(), codeunit 1890 "Reminder Communication" as follows:
/// Subscribe to this event to transfer custom fields from Reminder Text extensions to Reminder Attachment Text Line extensions.
/// </summary>
/// <param name="ReminderText">Source record containing the legacy reminder text data.</param>
/// <param name="ReminderAttachmentTextLine">Target record to be inserted with the new reminder attachment text line data.</param>
[IntegrationEvent(false, false)]
local procedure OnBeforeInsertReminderAttachmentTextLine(var ReminderText: Record "Reminder Text"; var ReminderAttachmentTextLine: Record "Reminder Attachment Text Line")
begin
end;
internal procedure TransferReminderText()
var
ReminderLevels: Record "Reminder Level";
ReminderText: Record "Reminder Text";
ReminderAttachmentText: Record "Reminder Attachment Text";
ReminderAttachmentTextLine: Record "Reminder Attachment Text Line";
ReminderEmailText: Record "Reminder Email Text";
Language: Codeunit Language;
TypeHelper: Codeunit "Type Helper";
ReadStream: InStream;
DefaultLanguageCode: Code[10];
LocalGuid: Guid;
begin
if ReminderText.IsEmpty() then
exit;
DefaultLanguageCode := Language.GetUserLanguageCode();
ReminderText.FindSet();
repeat
Clear(ReminderAttachmentText);
Clear(ReminderEmailText);
Clear(LocalGuid);
Clear(ReadStream);
// Check if there are existing texts for the reminder level
if ReminderLevels.Get(ReminderText."Reminder Terms Code", ReminderText."Reminder Level") then begin
if not IsNullGuid(ReminderLevels."Reminder Attachment Text") then
LocalGuid := ReminderLevels."Reminder Attachment Text";
if not IsNullGuid(ReminderLevels."Reminder Email Text") then
LocalGuid := ReminderLevels."Reminder Email Text";
if IsNullGuid(LocalGuid) then
LocalGuid := CreateGuid();
// If not then create the default ones
if not ReminderAttachmentText.Get(LocalGuid, DefaultLanguageCode) then
ReminderAttachmentText.SetDefaultContentForNewLanguage(LocalGuid, DefaultLanguageCode, Enum::"Reminder Text Source Type"::"Reminder Level", ReminderLevels.SystemId);
if not ReminderEmailText.Get(LocalGuid, DefaultLanguageCode) then
ReminderEmailText.SetDefaultContentForNewLanguage(LocalGuid, DefaultLanguageCode, Enum::"Reminder Text Source Type"::"Reminder Level", ReminderLevels.SystemId);
if ReminderAttachmentText.Get(LocalGuid, DefaultLanguageCode) and ReminderEmailText.Get(LocalGuid, DefaultLanguageCode) then
// And then personalized them with the customer data
case ReminderText.Position of
Enum::"Reminder Text Position"::Beginning:
begin
ReminderAttachmentTextLine.Init();
ReminderAttachmentTextLine.Id := ReminderAttachmentText.Id;
ReminderAttachmentTextLine."Language Code" := ReminderAttachmentText."Language Code";
ReminderAttachmentTextLine.Position := ReminderAttachmentTextLine.Position::"Beginning Line";
ReminderAttachmentTextLine."Line No." := ReminderText."Line No.";
ReminderAttachmentTextLine.Text := ReminderText.Text;
OnBeforeInsertReminderAttachmentTextLine(ReminderText, ReminderAttachmentTextLine);
ReminderAttachmentTextLine.Insert(true);
end;
Enum::"Reminder Text Position"::Ending:
begin
ReminderAttachmentTextLine.Init();
ReminderAttachmentTextLine.Id := ReminderAttachmentText.Id;
ReminderAttachmentTextLine."Language Code" := ReminderAttachmentText."Language Code";
ReminderAttachmentTextLine.Position := ReminderAttachmentTextLine.Position::"Ending Line";
ReminderAttachmentTextLine."Line No." := ReminderText."Line No.";
ReminderAttachmentTextLine.Text := ReminderText.Text;
OnBeforeInsertReminderAttachmentTextLine(ReminderText, ReminderAttachmentTextLine);
ReminderAttachmentTextLine.Insert(true);
end;
Enum::"Reminder Text Position"::"Email Body":
if ReminderText."Email Text".HasValue() then begin
ReminderText.CalcFields("Email Text");
ReminderText."Email Text".CreateInStream(ReadStream);
ReminderEmailText.SetBodyText(TypeHelper.TryReadAsTextWithSepAndFieldErrMsg(ReadStream, TypeHelper.LFSeparator(), ReminderText.FieldName("Email Text")));
end;
end;
end;
until ReminderText.Next() = 0;
end;
Internal work item: AB#623925
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
SCMGitHub request for SCM areaGitHub request for SCM areaevent-requestRequest for adding an eventRequest for adding an event