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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to Set the null default value in a lookup in a String edit control.

(0) ShareShare
ReportReport
Posted on by 454

Hi,

I want to set the Lookup that should be a null value in default in a Stringedit Control . I need some Assistance for this. Should we set this property by Code or Manually ? .

Thanks in Advance,

Ram.

I have the same question (0)
  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    You talk about two different things.

    A lookup is a form; it doesn't have any value.

    A string edit control does have a value and you surely can set it to an empty string (null isn't a valid string value in X++).

    Anyway, I think you should explain what you're trying to achieve from user's point of view; then we'll be able to decide what needs to be done technically.

  • Blue Wang Profile Picture
    on at

    HI Ram,

    Do you want to make the Lookup String control appear blank?

    1754.PNG

    How do you set up your form? Is the data source set? If so, clear it first. Then override the lookup () of the string control.

    48800.PNG

    As result: (You do not choose, it is blank)

    800067.PNG

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    No, overriding lookup() won't change the value. This method controls how the lookup form is built, when you try to expand the list of possible values.

  • Blue Wang Profile Picture
    on at

    Hi Martin,

    Thanks for your correction.

    I agree with what you said, it doesn't change the value.

    Is it possible that the data is empty because I cleared the data field of the String control and I override lookup () ,so the value is only displayed in the drop-down list?

    -

    My code:

         public void lookup()
            {
                SysTableLookup       sysTableLookup =   SysTableLookup::newParameters(tablenum(PhoneTable), this);
                Query                query = new Query();
                QueryBuildDataSource queryBuildDataSource;
                ;
    
                sysTableLookup.addLookupfield(fieldnum(PhoneTable, NewFieldString2));
                queryBuildDataSource = query.addDataSource(tablenum(PhoneTable));
                queryBuildDataSource.addSortField(fieldnum(PhoneTable, NewFieldString2));
                //queryBuildDataSource.addRange(fieldNum(PhoneTable, NewFieldString2)).value(queryNotValue(''));
                queryBuildDataSource.orderMode(ordermode::GroupBy);
                sysTableLookup.parmQuery(query);
                sysTableLookup.performFormLookup();
    
                super();
            }

  • Martin Dráb Profile Picture
    237,884 Most Valuable Professional on at

    Yes, clearing the value (setting it to an empty string) of the StringEdit controls is what changes the value displayed in the control. Lookup() method doesn't get execute at all unless you tried to expand the list of values, because what the method does it building the lookup form.

    You can easily test by adding a breakpoint to lookup() and attaching the debugger. You'll see at which moment the method executes.

  • Blue Wang Profile Picture
    on at

    Thank you very much .

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans