Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : 7ZSQ3FZfO2Oz4T+qgaGKlV
Small and medium business | Business Central, N...
Answered

How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?

Like (0) ShareShare
ReportReport
Posted on 27 Apr 2023 06:06:34 by 222

How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?I don not have any other unique value fields in this table and if I do not enter a value in this field page shows error

  • Verified answer
    Tech-Lucky Profile Picture
    844 on 27 Apr 2023 at 09:30:45
    RE: How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?

    See I understand your requirement you don't want to insert a record until and unless the other fields are filled right? to achieve this you can create a buffer page with variables only fill out the variables and check if all the variables have the values then only the record insert in your table, and to have a unique key you can do the code for auto-incremented unique no as an entry no in the primary key.

    i hope it helps you please verify the answer.

  • Verified answer
    Govinda Kumar Profile Picture
    2,211 Moderator on 27 Apr 2023 at 07:44:11
    RE: How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?

    Hi Pragya752,

    No, you cannot enter all fields before inserting the primary key, and it is not possible for any table to not have the primary key, note that the record is inserted as soon as you enter the primary key in business central, keeping that in mind you can add a procedure to insert all fields from somewhere else after inserting the primary key... so basically you are inserting all the other fields with primary key not before inserting the primary key..

    Here's the example where I'm inserting all the other fields from somewhere else as soon as the primary key is inserted.. 

    pastedimage1682581087729v1.png

    Hope it helps

    Regards

  • Suggested answer
    Shrey Chauhan Profile Picture
    274 on 27 Apr 2023 at 06:45:38
    RE: How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?

    for data filled in fields you can code on the table like

    TableRelation = TableName.primarykey;

               trigger OnValidate()

               var

                   var: Record TargetTableName;

               begin

                   var.Reset();

                   var.SetRange(primarykey, Rec."primarykey");

                   if var.FindFirst() then begin

                       fieldname := var.ieldname;

                       .

    .

    .

                   end;

               end;

    but you must specifiy the primary key in table and then you can access the data

    and it will fills the fields without editing or entering data.

    Hope this helps
    thank you

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,005 Moderator on 27 Apr 2023 at 06:24:27
    RE: How can i apply a validation on an input field in page level such that all other fields must be filled before allowing this field to get an input value.This field is my primary key.Can a table in bussiness central have no primary key ?

    No. A table must have a primary key and if you are doing the input in a page the primary key needs to be filled in first.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,442 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,575 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete