web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Newbie Question - Emptying field

(0) ShareShare
ReportReport
Posted on by 10

Hi,

I'm new to AL Code (Any coding at all), and did manage to make most of my code work, the one thing I'm missing is that I can't wrap my head around how to allow emptying a previously filled field, when doing validation.

When I try to delete the Customer No. in my "Partner No."-field it's not allowed.

Help is much appreciated.

My code for the field:

        field(80; "Partner No."; Code[20])
        {
            Caption = 'Partner no.';
            TableRelation = Customer."No.";

            trigger OnValidate()
            var
                Customer: Record Customer;
           
            begin
                Customer.Get("Partner No.");
                PartnerName := Customer.Name;
            end;
        }

Error message

pastedimage1645609187215v1.png

I have the same question (0)
  • Verified answer
    Bert Verbeek Profile Picture
    110 on at
    RE: Newbie Question - Emptying field

    You do a Customer.Get with an empty value. Just put an if statement around that one.

    If Customer.Get("Partner No.") then

  • Verified answer
    YUN ZHU Profile Picture
    93,915 Super User 2025 Season 2 on at
    RE: Newbie Question - Emptying field

    Hi, The following is some other solutions that I hope can help you.

    https://yzhums.com/22220/

    Thanks
    ZHU

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,225

#2
Sumit Singh Profile Picture

Sumit Singh 2,123

#3
YUN ZHU Profile Picture

YUN ZHU 1,813 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans