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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to Update a history table by considering field values as variables

(0) ShareShare
ReportReport
Posted on by 1,307

Hi,

we have to a list of variables from which we create labels for each customer. Each label will have an assortment of variables from the above list (E.g. ItemId).

So tables and forms are created for list of labels and the variables that are tied to the label. After label is generated, generated values needs to be updated in a HistoryTable.  History table has fields labelId and ItemId, etc.

(An example ) - ShipmentItemId is an x++ variable that holds data.

label Detail Table has following fields

label 1:

FieldID                FieldValue                         FieldConversion            FieldLength

ItemId                 ShipmentItemid                                                        20

here Itemid  has to be updated with ShipmentItemid value 'ITEM1'

Label 2:

FieldID                FieldValue                         FieldConversion            FieldLength

ItemId                 ShipmentItemid                Static Value   'MIXED'        20

here ItemId has to be updated with 'MIXED' (static text value) 

So when label1 is  generated, history table needs to be updated, as

LabelId        Itemid     ..........          RecId

label1          'ITEM1'    ..........         xxxxxxxxxx

When label2 is generated history table needs to be updated as

LabelId        Itemid      ..........         RecId

label2          'MIXED'     ...........        xxxxxxxxxx

I am trying to use  SysDictTable in a job to see how this works

static void Job8(Args _args)
{
   
    LabelsDtl              LabelsDtl;
    Historytable         Labels;
    LabelId                 _labelId = 'label1';
    SysDictTable        sysDictTable = new SysDictTable(tableNum(Historytable));
    SysDictField         sysDictField;
    int                        i;
    str                        fieldname, shipmentItemid = 'ITEM1';
    ;
    ttsBegin;
    Labels.clear();

    labels.labelid = _labelId;

    for(i=1;i<= sysDictTable.fieldCnt();i++)
    {
        ////*****  fieldname holds FieldID value of History table (here ItemId)

        fieldname = SysDictTable.fieldName(sysDictTable.fieldCnt2Id(i));             
       

        Labels.(SysDictTable.fieldName2Id(fieldname)) = LabelsDtl::find(_labelId,fieldname).FieldValue;
           
           
        print Labels.ItemId;
        pause;          
       
    }
    Labels.insert();
    ttscommit;
}

LabelsDtl::find(_labelId,fieldname).FieldValue is "ShipmentItemId" but I want the variable value 'ITEM1' to be populated at this place.

Could some one help me to sort this?

Thanks,

Lakshmi

*This post is locked for comments

I have the same question (0)

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans