Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

select record on the basis of field name

Posted on by 135

Hi There,

I need to select the table record on the basis of field name.

Below is the code i am using to get table fields

static void BEDictTable(Args _args)
{
mytablecustom lines;

str fieldName;
int day;

DictTable dt;
FieldId fieldId;
DictField dictField;

dt = new SysDictTable(tableNum(mytablecustom));

fieldId= dt.fieldNext(0);

while(fieldId)
{
dictField =dt.fieldObject(fieldId);

day = dayOfMth(today());
fieldName = "Day"+int2str(day);
if(dictField.name() == fieldName) // this is my custom field name 

{
select lines where lines.worker == "XXXXXX" and lines.    // how can i write one more condition for fetch the record from that column
}
fieldId= dt.fieldNext(fieldId);
}
}

In the select query i need to write one more condition on fieldName.

Can you please guide me how can i achieve my above requirement.

Thanks

*This post is locked for comments

  • Maahi P Profile Picture
    Maahi P 135 on at
    RE: select record on the basis of field name

    Hi Nikoloas,

    Thanks for your suggestion , it worked.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: select record on the basis of field name

    You don't need to pass the field name. Remember that qbds.addRange wants a field id as a parameter.

    So just use qbds.addRange(dictField.id()).value("5555");

  • Maahi P Profile Picture
    Maahi P 135 on at
    RE: select record on the basis of field name

    I tried to do it by QDBS as you suggeseted.

    but in this line i am getting error,

    qbds.addRange(fieldNum(Mytable, dictField.name()));///.value("5555");

    how can i pass the field name?

    thanks

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: select record on the basis of field name

    docs.microsoft.com/.../how-to-create-queries-by-using-x

    Is it clear?

  • Maahi P Profile Picture
    Maahi P 135 on at
    RE: select record on the basis of field name

    Hi Nikolaos Mäenpää,

    Thanks for your reply

    can you please show any example.

    Thanks

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: select record on the basis of field name

    It should be easy if you use a Query object instead of a select statement.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans