Skip to main content

Notifications

Business Central forum
Answered

how to validate if first name is empty then middle name not able to enter in the business central

editSubscribe (2) ShareShare
ReportReport
Posted on by 133
Can you please suggest me mentioned below codes are not working first name is blank then without any error msg middle name will accept.
 
 field(2; Studentfirstname; Text[100])
        {
            Caption = 'Student First Name';
            DataClassification = CustomerContent;
            trigger OnValidate()
            var
                myInt: Integer;
 
            begin
 
                Rec.Fullname := Rec.Studentfirstname + ' ' + Rec./student middle Name/ + ' ' + Rec.studentlastName;
                if (Rec.Studentfirstname = '') then
                begin
                       If (/student middle Name/<>'') then
                    begin
                        Error('You should Enter First Name');
                    end;
                end;
            end;
        }
 
Categories:
  • Verified answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 10,155 User Group Leader on at
    how to validate if first name is empty then middle name not able to enter in the business central
    Hi,
     
    In Middle Name on validate trigger just write -
     
    If (rec.Studentmiddlename <> xrec.Studentmiddlename) or (rec.Studentmiddlename <> '') then 
     Rec.Testfield(Studentfirstname);
    Regards,
    Saurav Dhyani
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 60,818 Super User on at
    how to validate if first name is empty then middle name not able to enter in the business central
    Hi, hope the following can give you some hints.
    Dynamics 365 Business Central: How to make a field mandatory
     
     
    Thanks.
    ZHU
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,311 User Group Leader on at
    how to validate if first name is empty then middle name not able to enter in the business central
    Hi @Ajay,
     
    I think you must add this code in "student middle name" validate method.
     
            field(XX; "student middle Name"; Text[100])
            {
                Caption = 'student middle Name';
                DataClassification = CustomerContent;
                trigger OnValidate() 
                begin
                    validate(Studentfirstname);
                end;
            }
    Also don't forget to add Rec.
     If (Rec."student middle Name"<>'') then
    Best regards,
    Mohamed Amine MAHMOUDI

Helpful resources

Quick Links

Take the Community feedback survey!

Answer this brief 15-question survey about your Community experience…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,375 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans