ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[Event Request] Table 5900 "Service Header"."Applies-to Doc. No."

Open Softstore opened this issue 5 years ago • 1 comments

lookup field 53 "Applies-to Doc. No" New event to give the possibility to validate if the field has been changed and to be able to update a new field that exists in the lines.

In table 36 there is the already created event to do this validation.

field(53; "Applies-to Doc. No."; Code[20]) { Caption = 'Applies-to Doc. No.';

trigger OnLookup()
var
	GenJnlLine: Record "Gen. Journal Line";
	GenJnlApply: Codeunit "Gen. Jnl.-Apply";
	ApplyCustEntries: Page "Apply Customer Entries";
	IsHandled: Boolean;
begin
	IsHandled := false;
	OnBeforeLookupAppliesToDocNo(Rec, CustLedgEntry, IsHandled);
	if IsHandled then
		exit;

	TestField("Bal. Account No.", '');
	CustLedgEntry.SetApplyToFilters("Bill-to Customer No.", "Applies-to Doc. Type".AsInteger(), "Applies-to Doc. No.", Amount);
	OnAfterSetApplyToFilters(CustLedgEntry, Rec);

	ApplyCustEntries.SetSales(Rec, CustLedgEntry, SalesHeader.FieldNo("Applies-to Doc. No."));
	ApplyCustEntries.SetTableView(CustLedgEntry);
	ApplyCustEntries.SetRecord(CustLedgEntry);
	ApplyCustEntries.LookupMode(true);
	if ApplyCustEntries.RunModal = ACTION::LookupOK then begin
		ApplyCustEntries.GetCustLedgEntry(CustLedgEntry);
		GenJnlApply.CheckAgainstApplnCurrency(
		  "Currency Code", CustLedgEntry."Currency Code", GenJnlLine."Account Type"::Customer, true);
		"Applies-to Doc. Type" := CustLedgEntry."Document Type";
		"Applies-to Doc. No." := CustLedgEntry."Document No.";
		**OnAfterAppliesToDocNoOnLookup**(Rec, CustLedgEntry);
	end;
	Clear(ApplyCustEntries);
end;

trigger OnValidate()
begin
	OnBeforeValidateAppliesToDocNo(Rec, CustLedgEntry);

	if "Applies-to Doc. No." <> '' then
		TestField("Bal. Account No.", '');

	if ("Applies-to Doc. No." <> xRec."Applies-to Doc. No.") and (xRec."Applies-to Doc. No." <> '') and
	   ("Applies-to Doc. No." <> '')
	then begin
		CustLedgEntry.SetAmountToApply("Applies-to Doc. No.", "Bill-to Customer No.");
		CustLedgEntry.SetAmountToApply(xRec."Applies-to Doc. No.", "Bill-to Customer No.");
	end else
		if ("Applies-to Doc. No." <> xRec."Applies-to Doc. No.") and (xRec."Applies-to Doc. No." = '') then
			CustLedgEntry.SetAmountToApply("Applies-to Doc. No.", "Bill-to Customer No.")
		else
			if ("Applies-to Doc. No." <> xRec."Applies-to Doc. No.") and ("Applies-to Doc. No." = '') then
				CustLedgEntry.SetAmountToApply(xRec."Applies-to Doc. No.", "Bill-to Customer No.");
end;

}

Softstore avatar Feb 25 '21 23:02 Softstore

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. We will update this issue with information about availability. 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.

JesperSchulz avatar Mar 22 '21 11:03 JesperSchulz