How do I select from table Common in AX?

16 11 2011

Workflow quite often uses fields such as ContextTableId and ContextRecId to reference the original document. I’ve been needing to get hold of the original database record as a Common object from which I can then do various things, but the question is how do i get that common object?

I’ve tried something like this

Common buffer;
;
select buffer where buffer.TableId == _tableId && buffer.RecId == _recId;

This however always return an empty buffer regardless of whether or not the record does exist. I eventually managed to retrieve a common record with the following method.

Common buffer;
SysDictTable dictTable;
;
dictTable = new SysDictTable(_tableId); buffer = dictTable.makeRecord(); select buffer where buffer.RecId == _recId;

I’ve needed to do this a couple of times in the past and kept forgetting, so I’m posting it here for myself and who ever else wants to accomplish this. Enjoy!

Advertisements

Actions

Information

2 responses

27 08 2012
lela

Hi,

great post, thank you!
My question is, how to take journal num from ledger journal table, if I have realtion in workflow tracking status table id of this table and reciid?

Thanks

15 04 2014
Bull

Nice!!

Simple and effective, just was I was looking for.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: