Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Thursday, December 22, 2016

EXPORT MODEL AND IMPORT MODEL FILES IN AX 2012 POWERSHELL AND CMD COMMAND PROMPT

EXPORT MODEL AND IMPORT MODEL FILES IN AX 2012 POWERSHELL AND CMD COMMAND PROMPT

Export an .axmodel file (Windows PowerShell)

  1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
  2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Export Command Syntax :
    Export-AXModel –Model <name> -File <Filename.axmodel>
    Example : 
    Export-AXModel –Model SecurityModel -File C:\SecurityModel.axmodel


Import an .axmodel file (Windows PowerShell)
    1. On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
    2. At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
    Import Command Syntax :
    Install-AXModel -File <Filename.axmodel> -Details
    Exmaple :
    Install-AXModel -File C:\SecurityModel.axmodel -Details

AX2012 AXUTIL commands to Import and Export Models

// Export
AxUtil export /model:"TestModel" /file:TestModel.axmodel

// Import
AxUtil import /file:TestModel.axmodel

C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities>AxUtil 

Monday, April 18, 2016

READ COMMA SEPARATED FILES : DYNAMIC AX CODE X++

READ COMMA SEPARATED FILES : DYNAMIC AX CODE X++
PUBLIC VOID READCOMMAFILE()
{
CommaTextIo         file;
container           line;
#define.filename(@'C:\\accounts.csv') #File
file = new CommaTextIo(#filename, #io_read);
if (!file || file.status() != IO_Status::Ok)
{
throw error("File cannot be opened.");
}
line = file.read();
while (file.status() == IO_Status::Ok)
{
info(con2Str(line, ' - '));
line = file.read();
                }


}

Outbound and Inbound file generation using File system adapater in AX 2012

Outbound  and Inbound file generation using File system adapter in AX 2012


Below is the code to generate the outbound xml file for the selected record.
static void GenerateXmlSelectedRecord(Args _args)
{
    AxdSendContext      axdSendContext  = AxdSendContext::construct();
    AifEntityKey        aifEntityKey    = AifEntityKey::construct();
    AifEntityKeyList    aifEntityKeyList = AifEntityKeyList::construct();
    Map                 keyData;
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    CustTable           custTable;
    int i,j;
    CustCustomerService CustCustomerService = CustCustomerService::construct();
    ;
    custTable = CustTable::find('Cust001');

    keyData = SysDictTable::getKeyData(custTable);
    aifEntityKey.parmTableId(custTable.TableId);
    aifEntityKey.parmRecId(custTable.RecId);
    aifEntityKey.parmKeyDataMap(keyData);

    aifEntityKeyList.addEntityKey(aifEntityKey);


    axdSendContext.parmXMLDocPurpose(XMLDocPurpose::Original);
    axdSendContext.parmSecurity(false);


    aifConstraint.parmType(AifConstraintType::NoConstraint) ;
    aifConstraintList.addConstraint(aifConstraint) ;

    info(strFmt("%1",custTable.AccountNum));
    AifSendService::SubmitDefault(  classnum(CustCustomerService),
                                aifEntityKey,
                                aifConstraintList,
                                AifSendMode::Async,
                                axdSendContext.pack());
}

Example: Generating the outbound xml file for all records( i.e. specified criteria on the query).
Below is the code to generate the outbound xml for all the records or specified criteria.

static void GenerateMutiplerecords(Args _args)
{
    CustTable           custTable;
    AxdSendContext      axdSendContext      = AxdSendContext::construct();
    AifEntityKey        aifEntityKey        = AifEntityKey::construct();
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    AifEndpointList     endpointList;
    AifActionId         actionId;
    Query               query;
    QueryBuildDataSource    qbds;

    query               = new Query(queryStr(AxdCustomer));
    AxdSend::removeChildDs(query);

    actionId            = AifSendService::getDefaultSendAction(classnum(CustCustomerService), AifSendActionType::SendByQuery);
    aifConstraint.parmType(AifConstraintType::NoConstraint);
    aifConstraintList.addConstraint(aifConstraint) ;
    endpointList        = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);

    AifSendService::SubmitFromQuery(actionId,endpointList,query,AifSendMode::Async);
}
Related Posts Plugin for WordPress, Blogger...