try this

Maybe some addings required:

check index and fields

- check availabilty of index and fields (maybe disabled - configurationkey
etc.)


obtaining the index

- use the first unique index if no PK is defined on table
- use recID if NO unoique index is defined on table

=== snip snip snip ==================================

static void GetPKValues(TableID _tid, recID _rid)
{
    DictTable       dt;
    DictIndex       di;
    Common          cm;
    IndexID         idx;
    int             i, iCnt;
    FieldID         fid;
    FieldID         fids[,10];
    int             fidsCnt = 0;
    str             s;
    str             sTemp;
    ;
    dt  = new DictTable(_tid);
    if (dt) {
        idx = dt.primaryIndex();
        if (idx) {
            di  = dt.indexObject(idx);
            if (di) {
                iCnt = di.numberOfFields();
                for (i=1;i<=iCnt;i++) {
                    fid = di.field(i);
                    if (fid) {
                        fidsCnt++;
                        fids[fidsCnt] = fid;
                    }
                }
            }
        }
        cm = dt.makeRecord();
        select firstonly * from cm
        where cm.RecId == _rid;
        if (cm.RecId) {
            // we've found the record;
            for (i=1;i<=fidscnt;i++) {
                fid   = fids[i];
                sTemp = strfmt('[%1]=[%2]',fieldId2Name(_tid, fid),
cm.(fid));
                if (s) s = s+',';
                s        = s + sTemp;
                info(s);
            }
        }
    }
}

=== snip snip end ==============================================


regards

Douglas

----- Original Message -----
From: "kamchung322" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, July 14, 2005 4:03 AM
Subject: [development-axapta] Find Record by TableId & RecId


> Hi All,
>
> I want to write an generic program.  I pass the tableid, recid and the
> program will display the Primary Key.  ie.  When I pass the tableid of
> ProdTable, it will display the ProdId.  When I pass the tableId of
> InventTable, it will display the ItemId.  Is it possible to do it and
> how to do ?
>
> Thank you very much.
>
> Kenneth.
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>





YAHOO! GROUPS LINKS




Reply via email to