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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

problem with created dialog

(0) ShareShare
ReportReport
Posted on by

i have problem with definitions created dialog

i put this code below it's was working on ax2009 but in ax2012r3 not wroking give me error on line 122

and when i press button dialog show me this

8712.Capture.JPG

what solve of this problem

2021.Capture.JPG

void clicked()
{
    Dialog dialog;
    DialogField dialogFileName;
    SysOperationProgress simpleProgress;
    Filename filename;
    FileIOPermission permission;
    TextIO textIO;
    NumberSeq numSeq;
    InventJournalTrans_Tag  inventJournalTrans_Tag;
    InventItemBarcode       inventItemBarcode;
    str s11,fileExtion ;
    str 30 barcodestr;
    container filterCriteria,tmpFilename;
    int I,noexit;
    InventDim inventDim;
    InventJournalTable      inventJournalTable ;
    InventBatchSerialId  inventBat;
    Container c1,c2;
    #File
    #avifiles

    ;
    dialog = new Dialog("@SYS28609"+"@SYS28426"+"@SYS26401"+" "+"@SYS15896");
    dialogFileName = dialog.addField(typeid(FilenameOpen),"@SYS53125");
    filterCriteria = ['*.txt'];
    filterCriteria = dialog.filenameLookupFilter(filterCriteria);
    dialog.run();
    if (dialog.run())
        {
            filename = dialogFileName.value();
            if(!filename)
            {
             Global::info("@SYS102056");
             throw Exception::Break;
            }
            else
            {
                tmpFilename=fileNameSplit(filename);
                fileextion=conPeek(tmpFilename,3);
                if(fileExtion!=".txt")
                {
                 Global::info(strFmt("%1",conPeek(tmpFilename,3))+"@SYS75113");
                 throw Exception::Break;
                 }
            }

        }
        else
        {
             throw Exception::Break;
        }
    permission = new fileIOpermission(filename,#io_read);

    permission.assert();
    textIO = new TextIO(filename,#io_read);
    textIO.inFieldDelimiter(';');///Change the Delimeter if it is , or ; etc
    simpleProgress = SysOperationProgress::newGeneral(#aviUpdate, 'Importing sales data',100);
    if(textIO)

    {
    numSeq = numberSeq::newGetNum(InventParameters::numRefInventJournalId());
            ttsbegin;
                    inventJournalTable.JournalId=numSeq.num();
                    inventJournalTable.JournalNameId=InventParameters::find(false).TagCountingJournalNameId;
                    if (!inventJournalTable.JournalNameId)
                        {
                             Global::info(strfmt("@SYS62961"));
                            throw Exception::Break;
                        }

                    inventJournalTable.initValue();
                    inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalTable.JournalNameId));
                    inventJournalTable.Description=InventJournalName::find(inventJournalTable.JournalNameId,false).Description +"/"+PerImportSetting.Name;
                    inventJournalTable.JournalType=InventJournalName::find(inventJournalTable.JournalNameId,false).JournalType;
                    inventJournalTable.InventDimFixed=259;
                    inventJournalTable.insert();
            ttscommit;
                    while(textIO.status() == IO_Status::Ok)

                    {
                    c1 = textIO.read();
                    s11 = conpeek(c1,2);
                    if(strlen(s11) > 1)
                    barcodestr=Conpeek(c1,2);
                    select firstonly InventItemBarcode
                    where  inventItemBarcode.itemBarCode==barcodestr;
                    if(inventItemBarcode.itemId)
                    {
                    ///
                    inventBat=Conpeek(c1,4);
                    if(inventBat!="" || inventBat!="0")
                        {
                       select firstonly inventDim
                        where inventDim.InventSiteId==PerImportSetting.InventSiteId &&
                            inventdim.InventLocationId==PerImportSetting.InventLocationId &&
                            inventdim.inventBatchId==inventBat;
                             Global::info(strfmt("@SYS54778",inventBat,barcodestr));

                        }
                        if(!InventDim.inventDimId)
                        {
                       select firstonly inventDim
                        where inventDim.InventSiteId==PerImportSetting.InventSiteId &&
                            inventdim.InventLocationId==PerImportSetting.InventLocationId;
                        }


                   ///
                /*    select firstonly inventDim
                    where inventDim.InventSiteId==PerImportSetting.InventSiteId &&
                     inventdim.InventLocationId==PerImportSetting.InventLocationId;*/
                    ttsbegin;
                      inventJournalTrans_Tag.journalId=inventJournalTable.JournalId;
                      inventJournalTrans_Tag.initValue();
                      inventJournalTrans_Tag.inventDimId=inventDim.inventDimId;
                      inventJournalTrans_Tag.itemId=inventItemBarcode.itemId;
                      inventJournalTrans_Tag.transDate=PerImportSetting.TransDate;
                      inventJournalTrans_Tag.qty=Conpeek(c1,3);
                      inventJournalTrans_Tag.tagId=int2str(I);
                      inventJournalTrans_Tag.lineNum=i+1;
                      inventJournalTrans_Tag.emplId=PerImportSetting.emplId;
                      inventJournalTrans_Tag.insert();
                      simpleProgress.incCount();
                      simpleprogress.setText(strfmt("@SYS54782", i));
                      i++;
                      sleep(10);
                    ttscommit;
                    Global::info(strfmt( "%1,%2,%3,%4" ,inventJournalTrans_Tag.itemId,inventJournalTrans_Tag.itemName()
                    ,inventJournalTrans_Tag.qty,barcodestr));
                    }
                    else
                     {                   {

                      noexit++;
                        Global::info(strfmt("@SYS98071",barcodestr));
                      }
                        }
                        }
                        select forUpdate inventJournalTable
                        where inventJournalTable.JournalId==inventJournalTrans_Tag.journalId;
                        ttsbegin;
                        inventJournalTable.NumOfLines=i;
                        inventJournalTable.update();
                        ttscommit;
     Global::info(strfmt("@SYS62960",inventJournalTable.JournalId,inventJournalTable.JournalType)+strfmt("@SYS54781",i,noexit));
    }

    }

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Anton Venter Profile Picture
    20,346 Super User 2025 Season 2 on at

    Hi, you have to use field Worker instead of EmplId. The Worker field relates to the HcmWorker table RecId Field.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    I can see two mistakes in your code

    1) TypeId has been replaced by extendedTypeStr in ax2012 so you have to write code as under

    dialogFileName = dialog.addField(typeid(FilenameOpen),"@SYS53125"); //wrong

    dialogFileName = dialog.addField(extendedTypeStr(FilenameOpen),"@SYS53125"); //correct as per ax2012

    2) EmplId has been replaced with HCMPersonnelNumberId ; and it is recommend to use HCMWokerRecId(EDT) as rerencegroup in ax2012

    belwo line of code is wrong in your code

    inventJournalTrans_Tag.emplId=PerImportSetting.emplId; //wrong code

    inventJournalTrans_Tag.Worker=PerImportSetting.AddNewFieldUsingEDThcmWokerRecId;

    //also you need data upgrade for your table PerImportSetting.

     

     



     

  • DMW Profile Picture
    on at

    thanks guys  for helping

  • DMW Profile Picture
    on at

    first code work with me but

    other second code not working i use this code

    inventJournalTrans_Tag.Worker=PerImportSetting.AddNewFieldUsingEDThcmPersonnelNumberId;

    rater than this below because i can't found this filed HCMWokerRecId to do relation with PerImportSetting table

    inventJournalTrans_Tag.Worker=PerImportSetting.AddNewFieldUsingEDThcmWokerRecId;

    but both of them show me error

    3554.Capture.JPG

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    AddNewFieldUsingEDThcmWokerRecId

    Means add a new field in you table PerImportSetting. the newly added field should be int64 type and should be extended from HCMWorkerRecId

  • DMW Profile Picture
    on at

    sorry i didn't see type of field thank you very much was very helping

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans