Service Header - CreateServiceLines Event OnCreateServiceLinesOnBeforeAssignType
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Why do you need this change?
In some implementations it is required to keep the line no. on recreating service lines. This is especially if linked tables are created which are depending on a consistent primary key of the service line table or printouts which relate to the line no. are already done. In the service module there are no events available to fullfill this task, in the purchase or sales area there are already such events.
Describe the request
Table 5900 "Service Header"
The change in the code includes one new event which allows to modify the service line record after assigning the line no. Also the temp service line can be modified if needed. The requested event is based on the already existing event in the sales module.
Old Code:
local procedure CreateServiceLines(var TempServLine: Record "Service Line" temporary; var ExtendedTextAdded: Boolean; var TempServiceCommentLine: Record "Service Comment Line" temporary)
var
ServiceTransferExtText: Codeunit "Service Transfer Ext. Text";
begin
ServLine.Init();
ServLine."Line No." := 0;
TempServLine.Find('-');
ExtendedTextAdded := false;
repeat
if TempServLine."Attached to Line No." = 0 then begin
ServLine.Init();
ServLine.SetHideReplacementDialog(true);
ServLine.SetHideCostWarning(true);
ServLine."Line No." := ServLine."Line No." + 10000;
ServLine."Price Calculation Method" := "Price Calculation Method";
ServLine.Validate(Type, TempServLine.Type);
if TempServLine."No." <> '' then begin
ServLine.Validate("No.", TempServLine."No.");
if ServLine.Type <> ServLine.Type::" " then begin
ServLine.Validate("Unit of Measure Code", TempServLine."Unit of Measure Code");
ServLine.Validate("Variant Code", TempServLine."Variant Code");
if TempServLine.Quantity <> 0 then
ServLine.Validate(Quantity, TempServLine.Quantity);
end;
end;
New Code with Event:
local procedure CreateServiceLines(var TempServLine: Record "Service Line" temporary; var ExtendedTextAdded: Boolean; var TempServiceCommentLine: Record "Service Comment Line" temporary)
var
ServiceTransferExtText: Codeunit "Service Transfer Ext. Text";
begin
ServLine.Init();
ServLine."Line No." := 0;
TempServLine.Find('-');
ExtendedTextAdded := false;
repeat
if TempServLine."Attached to Line No." = 0 then begin
ServLine.Init();
ServLine.SetHideReplacementDialog(true);
ServLine.SetHideCostWarning(true);
ServLine."Line No." := ServLine."Line No." + 10000;
ServLine."Price Calculation Method" := "Price Calculation Method";
OnCreateServiceLinesOnBeforeAssignType(ServLine, TempServLine); // <---- New Event
ServLine.Validate(Type, TempServLine.Type);
if TempServLine."No." <> '' then begin
ServLine.Validate("No.", TempServLine."No.");
if ServLine.Type <> ServLine.Type::" " then begin
ServLine.Validate("Unit of Measure Code", TempServLine."Unit of Measure Code");
ServLine.Validate("Variant Code", TempServLine."Variant Code");
if TempServLine.Quantity <> 0 then
ServLine.Validate(Quantity, TempServLine.Quantity);
end;
end;
Event definition:
[IntegrationEvent(false,false)]
local procedure OnCreateServiceLinesOnBeforeAssignType(var ServiceLine: Record "Service Line"; var TempServiceLine: Record "Service Line")
begin
end;
Provide an implementation (optional)
- I will provide the implementation for this extensibility request
Alternatives Evaluated: There is no event in this function to easily fullfill the needed data modification. Only a complete copy of the code and the usage of an IsHandled event in the caller function would be a possibility. This brings a lot of downsides with it.
Performance Considerations: No performance impact will be awaited as this function is used only occasionally
Data Sensitivity Review: No sensitive data exposed
Multi-Extension Interaction: As this event is intended to increase data quality and integrity, i dont see any issue in a multi extension area
Loop event justification: As the data can be set on each record speratly or case by case this has to be inside the loop
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the CreateServiceLines procedure in table 5900, Service Header, and compare the requested event with the existing sales-module event mentioned in the issue. Add the event definition and invocation at the indicated point, then verify that subscribers can modify Service Line and temporary Service Line values before Type is assigned.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100