Skip to content

KVSKBASalesHeader#

Events#

OnBeforeSetAssignedUserID(Record Sales Header, Boolean, Boolean) :#

Summary: Integration event raised before setting the assigned user ID on a sales header.

[IntegrationEvent(false, false)]
local procedure OnBeforeSetAssignedUserID(var SalesHeader: Record "Sales Header"; OnInsertMode: Boolean; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesHeader", 'OnBeforeSetAssignedUserID', '', false, false)]
local procedure DoSomethingOnBeforeSetAssignedUserID(var SalesHeader: Record "Sales Header"; OnInsertMode: Boolean; var IsHandled: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header where assigned user ID will be set
  • OnInsertMode: Indicates whether the procedure is called during insert operation
  • IsHandled: Set to true to skip default assigned user ID logic

Remarks: This event is triggered before the SetAssignedUserID procedure assigns a user to the sales header. Subscribe to this event to replace or extend the assignment logic, assign custom user IDs, or skip default assignment. Set IsHandled to true to prevent standard processing. The default logic assigns the current user based on responsibility center access. Useful for implementing custom user assignment rules, integrating with workflows, or applying conditional assignment logic based on document type or customer.

OnBeforeSetDefaultSalespersonOnSalesHeader(Record Sales Header, Boolean) :#

Summary: Integration event raised before setting default salesperson codes on a sales header.

[IntegrationEvent(false, false)]
local procedure OnBeforeSetDefaultSalespersonOnSalesHeader(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesHeader", 'OnBeforeSetDefaultSalespersonOnSalesHeader', '', false, false)]
local procedure DoSomethingOnBeforeSetDefaultSalespersonOnSalesHeader(var SalesHeader: Record "Sales Header"; var IsHandled: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header where salesperson codes will be set
  • IsHandled: Set to true to skip default salesperson logic

Remarks: This event is triggered before the SetDefaultSalespersonOnSalesHeader procedure determines salesperson codes. Subscribe to this event to replace or extend the defaulting logic, assign custom salespeople, or skip default assignment. Set IsHandled to true to prevent standard processing. The default logic uses a priority hierarchy considering ship-to address, customer, contact, user setup, and current user. Useful for implementing custom salesperson selection rules, integrating with sales team management, or applying conditional assignment based on customer segments or territories.

OnBeforeSetDefaultSalespersonOnSalesHeaderOnCaseElseTransfSalespfromCust(Record Sales Header, Record Sales & Receivables Setup, Boolean) :#

Summary: Integration event raised when an unexpected value is encountered in the Transfer Salesperson from Customer setup.

[IntegrationEvent(false, false)]
local procedure OnBeforeSetDefaultSalespersonOnSalesHeaderOnCaseElseTransfSalespfromCust(var SalesHeader: Record "Sales Header"; SalesReceivablesSetup: Record "Sales & Receivables Setup"; var IsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesHeader", 'OnBeforeSetDefaultSalespersonOnSalesHeaderOnCaseElseTransfSalespfromCust', '', false, false)]
local procedure DoSomethingOnBeforeSetDefaultSalespersonOnSalesHeaderOnCaseElseTransfSalespfromCust(var SalesHeader: Record "Sales Header"; SalesReceivablesSetup: Record "Sales & Receivables Setup"; var IsHandled: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header being processed
  • SalesReceivablesSetup: The Sales & Receivables Setup record
  • IsHandled: Set to true to skip the field error for unhandled transfer options

Remarks: This event is triggered in SetDefaultSalespersonOnSalesHeader when the Transfer Salesperson from Customer field contains a value other than 'Sell-to Customer' or 'Bill-to Customer'. Subscribe to this event to handle custom transfer options without raising an error. Set IsHandled to true to prevent the default field error. The default logic validates that only supported customer source options are used. Useful for extending the salesperson transfer logic with custom customer source options or alternative selection methods.

OnBeforeOnSalesHeaderOnBeforeUpdateLocationCode(Record Sales Header, Code[10], Boolean, Boolean) :#

Summary: Integration event raised before updating the location code on a sales header.

[IntegrationEvent(false, false)]
local procedure OnBeforeOnSalesHeaderOnBeforeUpdateLocationCode(var SalesHeader: Record "Sales Header"; LocationCode: Code[10]; var BaseAppPublisherIsHandled: Boolean; var KBALogicIsHandled: Boolean): 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBASalesHeader", 'OnBeforeOnSalesHeaderOnBeforeUpdateLocationCode', '', false, false)]
local procedure DoSomethingOnBeforeOnSalesHeaderOnBeforeUpdateLocationCode(var SalesHeader: Record "Sales Header"; LocationCode: Code[10]; var BaseAppPublisherIsHandled: Boolean; var KBALogicIsHandled: Boolean)
begin
end;

Parameters:

  • SalesHeader: The sales header being processed
  • LocationCode: The location code being updated
  • BaseAppPublisherIsHandled: Set to true to skip the further code of the calling standard function
  • KBALogicIsHandled: Set to true to skip the further code of the KBA-specific logic

Remarks: This event is triggered in the OnSalesHeaderOnBeforeUpdateLocationCode subscriber. Subscribe to this event to implement custom logic for determining the location code on a sales header, or to override the default logic entirely. Set BaseAppPublisherIsHandled to true to skip the standard location code update logic, and set KBALogicIsHandled to true to skip the KBA-specific location code update logic. The default kba logic prioritizes setting the location code based on the responsibility center's location, followed by the sales order type's location. Useful for scenarios where location code determination needs to consider additional factors such as customer preferences, inventory availability, or specific business rules.