Tuesday, July 28, 2015

Ambil Nama File dari File yang dipilih dari Dialog Box - AX 2012

static void Test_GetFileName(Args _args)
{
    container            segments, segmentReset;
    str                  annotatedFormat, format;

    CommaTextIo           file;
    container             rec,filterCriteria;
    Filename              filename,filenamex;

    int                 sep,i;
    Dialog              d;
    DialogField         df1;

    Filename filepathz;
    Filename filenamez;
    Filename fileTypez;
    str fileNameString;
    ;
    d = new Dialog("Import Item Price Discount");
    df1 = d.addField(ExtendedTypeStr("FilenameOpen"));
    filterCriteria  = ['*.txt','*.txt'];//// To filter only TXT files
    filterCriteria  = d.filenameLookupFilter(filterCriteria);
 

    d.run();

    if(d.run())
    fileName        = df1.value();

    if(!fileName)
    {
        return;
    }

    filenamex = filename;

    [filepathz, filenamez, fileTypez] = fileNameSplit(filenamex);
    fileNameString= filenamez + fileTypez;

    info(strFmt('Full path: %1',filenamex));
    info(strFmt('File name: %1',fileNameString));

}

No comments:

Post a Comment