Tuesday, 17 April 2018

Generate file name with time and random number X++

static str getFileName(str _fileName)
{
    str             lFileName;
    UtcDateTime     dateTime = DateTimeUtil::getSystemDateTime();
    int             randomNumber;
    str             hours = '';
    str             minutes = '';
    str             seconds = '';
    str             yyyy = '';
    str             mm = '';
    str             dd = '';

    randomNumber = 0;
    randomNumber = xGlobal::randomPositiveInt32();

    hours   = int2str(DateTimeUtil::hour(dateTime));
    minutes = int2str(DateTimeUtil::minute(dateTime));
    seconds = int2str(DateTimeUtil::second(dateTime));
    yyyy    = int2str(DateTimeUtil::year(dateTime));
    mm      = int2str(DateTimeUtil::month(dateTime));
    dd      = int2str(DateTimeUtil::day(dateTime));
   
    hours   = (strLen(hours) == 1) ? '0' + hours : hours ;
    minutes = (strLen(minutes) == 1) ? '0' + minutes : minutes ;
    seconds = (strLen(seconds) == 1) ? '0' + seconds : seconds ;
    mm      = (strLen(mm) == 1) ? '0' + mm : mm ;
    dd      = (strLen(dd) == 1) ? '0' + dd : dd ;
   
    lFileName = strFmt('%1_%2%3%4_%5%6%7_%8.xml',lFileName,yyyy,mm,dd,hours,minutes,seconds,randomNumber);
    return lFileName;

}

No comments:

Import and Export file from BLOB storage Account(Azure) in D365 F&O using X++

  Import and Export file from BLOB storage Account in D365 F&O using X++ Import: /// <summary> /// MKInventQualityOrderLineService...