Table 27 Item - Multiple events
It should be possible to extend the CheckDocuments() procedure in order to add an additional check on custom fields from different apps. Currently, it only prevents change of field Type. Please add a publisher in the following procedure as in the example: CheckBOM(CurrFieldNo); CheckPurchLine(CurrFieldNo); CheckSalesLine(CurrFieldNo); CheckProdOrderLine(CurrFieldNo); CheckProdOrderCompLine(CurrFieldNo); CheckPlanningCompLine(CurrFieldNo); CheckTransLine(CurrFieldNo); CheckServLine(CurrFieldNo); CheckProdBOMLine(CurrFieldNo); CheckServContractLine(CurrFieldNo); CheckAsmHeader(CurrFieldNo); CheckAsmLine(CurrFieldNo); CheckJobPlanningLine(CurrFieldNo);
Example:
local procedure CheckPurchLine(CurrFieldNo: Integer)
var
PurchaseLine: Record "Purchase Line";
begin
PurchaseLine.SetCurrentKey(Type, "No.");
PurchaseLine.SetRange(Type, PurchaseLine.Type::Item);
PurchaseLine.SetRange("No.", "No.");
if PurchaseLine.FindFirst() then begin
if CurrFieldNo = 0 then
Error(Text000, TableCaption, "No.", PurchaseLine."Document Type");
if CurrFieldNo = FieldNo(Type) then
Error(CannotChangeFieldErr, FieldCaption(Type), TableCaption, "No.", PurchaseLine.TableCaption);
**OnAfterFindPurchaseLineOnCheckPurchLine(CurrFieldNo);**
end;
end;
[IntegrationEvent(false, false)]
local procedure OnAfterFindPurchaseLineOnCheckPurchLine(CurrFieldNo: Integer)
begin
end;
There is already OnAfterCheckDocuments(Rec, xRec, CurrFieldNo); where you can add all the checks you want, can you use that? It's much preferable than adding so many events for the same purpose.
Well, we are trying not to copy the same code as in BaseApp multiple times. For example, we would have to add the same procedures (the ones that I listed above) and add the same checks as in BaseApp just to be able to check field that is not Type. Is there a way you can make standard procedures more generic, something like:
local procedure CheckPurchLine(CurrFieldNo: Integer; **FieldNo: Integer; FieldCaption: Text**)
var
PurchaseLine: Record "Purchase Line";
begin
PurchaseLine.SetCurrentKey(Type, "No.");
PurchaseLine.SetRange(Type, PurchaseLine.Type::Item);
PurchaseLine.SetRange("No.", "No.");
if PurchaseLine.FindFirst() then begin
if CurrFieldNo = 0 then
Error(Text000, TableCaption, "No.", PurchaseLine."Document Type");
if CurrFieldNo = **FieldNo** then
Error(CannotChangeFieldErr, **FieldCaption**, TableCaption, "No.", PurchaseLine.TableCaption);
end;
end;
In this way we could just pass the parameters we want to be compared.
Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.
Build ID: 51281.