Thursday, 29 May 2014

Purchase order- line number increments

  1. Click System administration > Setup > System parameters.
  2. Click General, and then select options for the general system parameters:
    • Increment – Enter the increment to use when new line numbers are assigned to purchase order lines. This increment is used for all purchase order lines. Line increments are applied for purchase orders only.

Monday, 26 May 2014

Make update changes on Packing slip post?

Many times we are required to make certain changes right after the packing slip has been posted. To do that, use the EndPost() method in the SalesPackingSlipJournalPost class. This method is called after the packing slip is successfully posted.

Friday, 16 May 2014

Job to fetch entry points for a Role in AX 2012 security

static void JobSecurityRoleEntryPoints(Args _args)
{
  SecurityTaskEntryPoint  taskEntryPoint;
    SecurityRole            role;
    SecurityRoleTaskGrant   taskGrant;
    SecuritySubTask         subTask;
    SecurityTask            privilege;
    SecurityTask            securityTask;
    SecurableObject         securableObject;
    RecId                   roleRecId;

    #AOT
    str userlicense, maintainlicense, privName;
    TreeNode treeMenuItem;
    TreeNode treeMenu;

    while select RecId, Name from role where role.AotName == 'TradeCustomer'
    {
        roleRecId = role.RecId;

        while select securityTask, SecurityRole from taskGrant
            join RecId, Type, AOTName from securitytask where securityTask.RecId == taskGrant.SecurityTask
                && taskGrant.SecurityRole == roleRecId && securitytask.Type == SecurityTaskType::Duty
            join securityTask, SecuritySubTask from subTask where subTask.SecurityTask == securityTask.RecId
            join securityTask, EntryPoint from taskEntryPoint where taskEntryPoint.SecurityTask == subtask.SecuritySubTask

            {
               select RecId, Type, Name from securableObject
                    where securableObject.RecId == taskEntryPoint.EntryPoint && (securableObject.Type == SecurableType::MenuItemDisplay
                        || securableObject.Type == SecurableType::MenuItemAction || securableObject.Type == SecurableType::MenuItemOutput);

                if( securableObject)
                {
                    select RecId, Type, AOTName from privilege where privilege.RecId == subTask.SecuritySubTask && SecurityTaskType::Privilege == privilege.Type;

                    privName = privilege.AotName;

                    info(strFmt("Role: %1   Duty: %2   Priv:  %3   Menu item : %4", role.Name,securitytask.AotName,privName,securableObject.Name));

                }
        }
       
        //sometimes a role has a privielge direclty assigned instead of a duty. So this code is for those privileges. In this case duty will not exist.
        while select SecurityTask, SecurityRole from taskGrant
            join RecId, Type, AOTName from securitytask where securityTask.RecId == taskGrant.SecurityTask
                 && taskGrant.SecurityRole == roleRecId && securitytask.Type == SecurityTaskType::Privilege
            join securityTask, EntryPoint from taskEntryPoint where taskEntryPoint.SecurityTask == securitytask.RecId

            {
                select RecId, Type, Name from securableObject
                    where securableObject.RecId == taskEntryPoint.EntryPoint && (securableObject.Type == SecurableType::MenuItemDisplay
                        || securableObject.Type == SecurableType::MenuItemAction || securableObject.Type == SecurableType::MenuItemOutput);

                if( securableObject)
                {
                   info(strFmt("Role: %1   Duty:   Priv:  %2   Menu item : %3", role.Name,securitytask.AotName,securableObject.Name));
                }
        }
    }
}

Thursday, 17 April 2014

How do I refresh AIF service schema after the Query is refreshed?

Go to AOT/Forms. Locate the AifService form. Select your particular service and simply click refresh.
Also make sure that in your outbound port, go to Data policies and make sure your newly added fields are marked Enabled otherwise they would not show up on the form.

Jobs that must be running for EDI documents in AX 2012

Four tasks that must be running periodically as a batch job in order for the EDI processing to occur are as below. Note that the order of their execution matters. If these jobs are not in Waiting state, then the Queue manager will show your document in Ready state and will never process it.

The four services that move documents through the gateway queue are:
  1. AIFGatewayReceiveService – This service communicates with the adapters, receives messages from their external source locations, and puts them into the gateway queue to wait for processing.
  2. AIFInboundProcessingService – This service takes incoming messages from the gateway queue and then processes the documents according to the rules that are specified by the inbound port.
  3. AIFOutboundProcessingService – This service processes an outbound document according to the rules that are specified by the integration port and then adds the envelope XML code to create a fully-formed AIF message. The service then places the message into the gateway queue to send.
  4. AIFGatewaySendService – This service sends the messages to the correct external destinations.
These services must run in a specific order because they depend on each other. For example, the gateway receive service must run before the inbound processing service. Otherwise, the inbound processing service will have no data to process. The order in which these services must run is the order in the previous list.

Tuesday, 15 April 2014

Configure an AOS instance to print [AX 2012]

A great technet article explaining how can you set up printers for printing business documents in AX 2012.

http://technet.microsoft.com/en-us/library/aa569633.aspx

Tuesday, 8 April 2014

Job to import customer contact information- Logistics electronic address

static void CustomerContactInformationJob(Args _args)
{
#File
    CommaTextIo        commaTextIo;
    FileIOPermission   permission;
    container          containFromRead;
    int                x;
    int                cols;
    int rowNum;

    str Customer,Description,Type,Locator;
    int Done,UnDone;

    CustTable custTAble;
    DirPartyContactInfoView DirPartyContactInfoView;
    DirParty dirParty;
    List locatorList;
    ListEnumerator locatorListEnumerator;
    SysDictEnum dictEnum;
    int         enumValue;

    ;
    permission = new FileIOPermission(@'C:\Users\Administrator\Desktop\Data\CustomerContacts.csv',#io_read);
    permission.assert();

    commaTextIo = new CommaTextIO(@'C:\Users\Administrator\Desktop\Data\CustomerContacts.csv','R');

    rowNum = 0;
    Done= 0;
    UnDone= 0;

    containFromRead = commaTextIo.read();

    dictEnum = new SysDictEnum(enumNum(LogisticsElectronicAddressMethodType));

    While(containFromRead)
    {
        if(rowNum>0)
        {
            Customer= any2str(conpeek(containFromRead,1));
            Description= any2str(conpeek(containFromRead,2));
            Type= any2str(conpeek(containFromRead,3));
            Locator= any2str(conpeek(containFromRead,4));

            custTable =CustTable::find(Customer);

    if(custTable)
        {
            dirParty = dirParty::constructFromPartyRecId(custTAble.Party);

            locatorList = strSplit(Locator, ";");
            locatorListEnumerator = locatorList.getEnumerator();

            while ( locatorListEnumerator.moveNext())
            {

                DirPartyContactInfoView.Locator = locatorListEnumerator.current();
                DirPartyContactInfoView.Type =   dictEnum.name2Value(Type);

                DirPartyContactInfoView.Party =   custTable.Party;
                DirPartyContactInfoView.LocationName = Description;
                dirParty.createOrUpdateContactInfo(DirPartyContactInfoView);

                DirPartyContactInfoView.clear();
                Done++;

            }



        }
        else
        {
            info("Customer not found " + Customer);
            UnDone++;
        }


        }
        containFromRead = commaTextIo.read();
        rowNum++;
    }
    commaTextIo = null;

    info(strFmt("Inserted : %1 Not inserted: %2", Done, UnDone));
}

tags: Ax 2012 Customer contact information ; Logistics Electronic address; importing contacts from csv using x++;