-
Notifications
You must be signed in to change notification settings - Fork 689
Description
Why do you need this change?
Describe why the change is needed
It is possible to extend the related Enum "Contact Business Relation" & "Contact Business Relation Link to Table" as per any standard Enum however due to the isolation of GetSelectedRelationCodes() and AppendFilter(var FilterValue: Text; Operator: Text; ValueToAdd: Text) it is not currently possible to correctly select the "Contact Business Relation" as part of the standard process.
Without these changes all of the links are set to "Other" and need correcting.
Describe the request
Describe the requests
In the Contact table when the OnInsert() trigger is called on creation of a new record or on the update of the field "Company No." it will call UpdateBusinessRelation() which in turn calls GetBusinessRelation() to try to find the business relation records for the Contact and set the field correctly:
local procedure GetBusinessRelation() ResultContactBusinessRelation: Enum "Contact Business Relation";
var
ContactBusinessRelation: Record "Contact Business Relation";
AllBusinessRelationCount, SelectedBusinessRelationCodeCount : Integer;
begin
FilterBusinessRelations(ContactBusinessRelation, Enum::"Contact Business Relation Link To Table"::" ", true);
AllBusinessRelationCount := ContactBusinessRelation.Count();
if AllBusinessRelationCount = 0 then **/// The Contact Business Relation with our extended Enum value exists so this returns 1**
exit(ResultContactBusinessRelation::None);
ContactBusinessRelation.SetFilter("Business Relation Code", GetSelectedRelationCodes()); /// GetSelectedRelationCodes() only sets the filter for the default Enum values and therefore...
ContactBusinessRelation.SetFilter("No.", '<>''''');
SelectedBusinessRelationCodeCount := ContactBusinessRelation.Count();
if SelectedBusinessRelationCodeCount = 0 then begin **/// This will be set to 0 which in turn...**
if AllBusinessRelationCount = 1 then
exit(ResultContactBusinessRelation::Other); **/// Ends up with our Contact Business Relation field being set to Other even though we have extended the Enum and would like to use that value.**
exit(ResultContactBusinessRelation::Multiple);
end;
if (AllBusinessRelationCount = 1) and (SelectedBusinessRelationCodeCount = 1) then begin
ContactBusinessRelation.SetLoadFields("Link to Table");
ContactBusinessRelation.FindFirst();
exit(ContactBusinessRelation."Link to Table"); **/// If the filter had been set correctly then this is where we would naturally end up and it would return with the value from the Contact Business Relation field where we've extended the Enum as we required.**
end;
exit(ResultContactBusinessRelation::Multiple);
end;
EventRequest
I think the least impact would be to allow third parties to append to the filter in this code:
local procedure GetSelectedRelationCodes() CodeFilter: Text;
begin
if SelectedBusRelationCodes <> '' then
exit(SelectedBusRelationCodes);
MarketingSetup.GetRecordOnce();
AppendFilter(CodeFilter, '|', MarketingSetup."Bus. Rel. Code for Customers");
AppendFilter(CodeFilter, '|', MarketingSetup."Bus. Rel. Code for Vendors");
AppendFilter(CodeFilter, '|', MarketingSetup."Bus. Rel. Code for Bank Accs.");
AppendFilter(CodeFilter, '|', MarketingSetup."Bus. Rel. Code for Employees");
OnPopulateCodeFilterWithDefaultValues(var CodeFilter); /// New event
SelectedBusRelationCodes := CodeFilter;
end;
[IntegrationEvent(false,false)]
local procedure OnPopulateCodeFilterWithDefaultValues(var CodeFilter: Text)
begin
end;
This should allow any third party who has extended the Enum values for Contacts & associated Business Relations to allow all of the standard processing to correctly assign those values without needing extra processing after all of the standard process has finished.
Internal work item: AB#622450