Hi all,
I need to validate customer name during creation of a new customer such that the creator must enter at least two strings i.e., you should not enter one name but at least two separated by a space.
How can I achieve this in OnAfterValidate or OnBeforeValidate trigger?
Hi Romryan,
have a look at String Functions.
You could use strpos to get the position of a space, and then check if it's not at the first or last index of the string. (maxstrlen)
You can try the below code
[EventSubscriber(ObjectType::Table, Database::Customer, 'OnAfterValidateEvent', 'Name', false, false)]
local procedure OnAfterValidateEventName(var Rec: Record Customer; var xRec: Record Customer; CurrFieldNo: Integer)
var
SpacePos: Integer;
begin
SpacePos := StrPos(Rec.Name, ' ');
if SpacePos > 0 then
if CopyStr(Rec.Name, SpacePos + 1, MaxStrLen(Rec.Name)) <> '' then
exit;
Error('Please enter name with a space.');
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156