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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

update and select count from common table. The table Common does not contain the field XXX.

(0) ShareShare
ReportReport
Posted on by 2,240

How can I select count from Common table and also update it using update_recordset? 

(common table sounds weird, How to frame it in a better technical way?)

Was trying something like below, but it doesn't works:

SysDictTable dt = SysDictTable::newName('Table1');

Common common = dt.makeRecord();



select count(Column1) from common;



update_recordset common

setting column1=0;


Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi MYGz ,

    public Common findRecord(TableId _tableId, RecId _recId, Boolean _forUpdate = false)
    {
        Common      common;
        DictTable   dictTable;
        ;
        dictTable = new DictTable(_tableId);
        common = dictTable.makeRecord();
     
        common.selectForUpdate(_forUpdate);
     
        select common
        where common.RecId == _recId;
     
        return common;
    }


  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at
    public void updateValue(TableId _tableId, RecId _recId, str _field, AnyType _value)
    {
        Common      common;
        Int         fieldId;
        ;
        ttsbegin;
        common = findRecord(_tableId, _recId, true);
        fieldId = fieldname2id(_tableId,_field);
     
        if (fieldId && _value)
        {
            common.(fieldId) = _value;
            common.update();
        }
        ttscommit;
    }
  • Verified answer
    Hossein.K Profile Picture
    6,648 on at

    Count of Common:

    public Common CountRow(TableId _tableId, Boolean _forUpdate = false)
    {
        Common      common;
        DictTable   dictTable;
        ;
        dictTable = new DictTable(_tableId);
        common = dictTable.makeRecord();
     
        common.selectForUpdate(_forUpdate);
     
        select count(RecId) common
        
     
        return common.RecId;
    }


  • MYGz Profile Picture
    2,240 on at

    Thanks. I'm still looking if update_recordset can be used with a common table.

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

News and Announcements

Season of Giving Solutions is Here!

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans