Thursday, January 12, 2017

X++ code to Move file from one folder to another folder in Ax 2012

Hi Reader's,

Here the post to move files from one folder to another folder in ax 2012.


static void MoveFilesFromFoldertoAnotherFolder(Args _args)
{
 FilenameOpen fileNameOpen;
 DialogField dialogFileName;
 Dialog dialog;
 Filename filePath;
 Filename fileName;
 Filename fileType;
 FileName DestinationPath;
 #File

 ;
DestinationPath = @'C:\Users\shiva.p\Desktop\Dest\'; // Define your Destination Path
 dialog = new Dialog("Move Files");

 dialogFilename = dialog.addField(extendedTypeStr(FileNameOpen));

dialog.filenameLookupFilter([#AllFilesType]);
 dialog.filenameLookupTitle("Select File");
 dialog.caption("Move File");
 dialogFilename.value(fileName);
if(!dialog.run())
 return;
filenameOpen = dialogFilename.value();
 [filePath, fileName, fileType] = fileNameSplit(fileNameOpen);
// MoveFile - The Original File won't be available once it's moved into destination path
WinAPI::moveFile(fileNameOpen, DestinationPath+FileName+FileType);
// CopyFile - The Original File will be available even if it's moved into destination path
 //WinAPI::copyFile(fileNameOpen, DestinationPath+FileName+FileType);
// DeleteFile - Delete the Selected File
 //WinAPI::deleteFile(fileNameOpen);

 // If u need to Use this in Form Take look in AOT > Forms > Tutorial_Form_File
}


Sunday, January 1, 2017

Use of SysListPanelRelationTable application class in AX 2012


Hi Folks,

Wish u a Very Happy  & Prosperous New Year 2017 !!!

Hey its New Year Lets Start learning new things !!
Here we go with a new concept to learn about SysListpanelrelationtable

https://sharingpointofax.wordpress.com/2013/03/11/use-of-syslistpanelrelationtable-application-class-2/


Thursday, December 29, 2016

Regular Expression in AX 2012

X++ code to validate Name using Regular Expression in AX 2012


public bool validateName(str _name)
{

    System.Text.RegularExpressions.Match regExMatch;
    bool                                 isValid;

    // verify that Name doesn’t contain bad special character like <>:”/\|?*
    // other characters used in the regular expression are part of regex syntax. 

    regExMatch = System.Text.RegularExpressions.Regex::Match(_name, @’^[^<>:"/\\|?*]*$’);
   
    // return true if name matches the criteria otherwise return false
    isValid = regExMatch.get_Success();   

    return isValid;
}

X++ code to validate Mobile no. in Ax 2012

static void MobilennoValidation(Args _args)
{

    boolean ret;
    #define.alphabets('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    #define.numbers('0123456789')
    int len;
    str  subst,keepnum;
    str Mobile;
    Mobile = "9876543210";
    len = strLen(Mobile);
    subst= substr(Mobile,1,len);
    keepnum=strkeep(substr(Mobile , 1, len), #numbers);

    if(len!=10)
    {
         checkFailed("@DMS1713");
    }

    else if((Mobile)&&(keepnum!=subst))
    {
         checkFailed("@DMS1678");
    }
    else
    {
        info("Mobile no, is validated successfully");
    }
}


X++ code to cancel Sales order and Purchase orders in AX 2012



                   
X++ Code to cancel Sales order

static void DMSSOCancel(Args _args)
{
    SalesTable salestable;
    SalesUpdateRemain SalesUpdateRemain;

    changeCompany('f898')
    {

        salestable = salestable::find("F898-000460");

        SalesUpdateRemain::cancelRemainderOnOpenSalesLines(salestable);

    }
}


X++ Code to cancel Purchase order
static void DMSCancelPO(Args _args)
{
    PurchFormLetter Purch;
    PurchTable PurchTable;
    PurchCancel PurchCancel ;

    changeCompany("f898")
    {
        PurchTable =PurchTable::find("F898-000079");

        PurchCancel = PurchCancel::construct();
        PurchCancel .parmPurchTable(PurchTable);
        PurchCancel .run();
    }

}

Friday, November 18, 2016

Product name is missing while importing Produtcs and products masters through DIXF in AX 2012

Hi folks,

Hope u guys are doing well,

After long gap today im going to tell small trick i.e

Product name is missing while importing Produtcs and products masters through DIXF in AX 2012

Solution : just go to Systemparameters table and open it and check the systemlanguageid field data whether the imported Product and Product master Language id and systemlanguageid is same or not,if not please make sure it should be same .

Keep Daxing Guys !!!

Have a great weekend !!!

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...