Monday, November 16, 2015

Calculating sales price

To calculate sales price of an item first you need to setup few things in Retail.

1) Ensure your login is linked to one of the retail channels.

2) 1.      If you want any price or discounts to appear on the sales line then affiliation and product setup needs to be performed
a.      Affiliation: Ensure the customer is linked to an affiliation

a.      Ensure that the item is linked to a proper product category.


Now use code sample mentioned in this blog to calculate sales price of an item.

Cheers!


Thursday, September 3, 2015

Creating and retrieving document notes through AIF

Document notes are not accessible from outside AX client(EP, AIF etc) if the restriction property is set as internal, while creating document note through AIF you can specify restriction property to do this set Restriction property as "External" and set  RestrictionSpecified to True.

To set restriction on header specify these two properties,
and to set restriction on line,


Cheers!

Thursday, July 2, 2015

Invalid data container type

You might get this issue while working on web service(.NetTcp adopter) in VS or during execution of AIF document service generation wizard.

To fix this issue you have to merge the macro from the several layers so every DataContainerType of both standard AX and your custom services are mentioned.If you still see this error after merging DataContainerTypes macro do compile forward for "AfStronglyTypedDataContainer" class.

Cheers!

Monday, June 8, 2015

Reference lookup for Customer delivery address

Before writing custom lookup first you have to add reference control in your form and you have to specify some properties as shown in the screen shot below,

Now override "lookupReference" method of your reference control and add following code,

public Common lookupReference()
{
    CustTable                   custTable;
    DirPartyTable               dirPartyTable;
    DirPartyLocation            dirPartyLocation;
    LogisticsPostalAddress      logisticsPostalAddress;
    SysReferenceTableLookup     sysRefTableLookup;
    Query                       lookupQuery = new Query();
    QueryBuildDataSource        lookupQueryDataSource;

    // Construct the SysRefTableLookup object
    sysRefTableLookup = SysReferenceTableLookup::newParameters(tableNum(LogisticsPostalAddress), ReferenceGroup);

    // Add the field list that will be displayed on the lookup form
   // You can Change/Add more fields in lookup based on your requirement.

    sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Address));
    sysRefTableLookup.addLookupfield(fieldNum(LogisticsPostalAddress, Location));

    // Construct the query's data source
    lookupQueryDataSource = lookupQuery.addDataSource(tableNum(LogisticsPostalAddress));

// To add multiple values in range.
    while select  Location from LogisticsPostalAddress
        join DirPartyLocation
        join dirPartyTable
        join custTable
            where logisticsPostalAddress.Location == dirPartyLocation.Location
                && dirPartyLocation.Party == custTable.Party
                && custTable.Party == DirPartyTable.RecId
                && custTable.AccountNum == ADCAutodesaCustomerInfo.CustAccount
    {
        // Add ranges to the query data source
        lookupQueryDataSource.addRange(fieldNum(LogisticsPostalAddress, Location)).value(queryValue(LogisticsPostalAddress.Location));
    }


    // Pass the query to the lookup object
    sysRefTableLookup.parmQuery(lookupQuery);

    return sysRefTableLookup.performFormLookup();
}

after adding this code compile your form/project to reflect the changes on form.


Cheers!

Thursday, June 4, 2015

Dynamics AX AIF Services Error: "Type 'http://schemas.microsoft.com/dynamics/2008/01/sharedtypes:AxdExtType_CFPSId_BR' is not declared."

You might get this or similar error when you activate inbound/outbound port or view document schema from data policies, To resolve this error all you need to do is
refresh AIF Services as shown below,


If you are still getting this error this means there are some errors in one or more objects related to the service you are trying to use, To get rid of this perform following steps

1) Identify objects that are causing this issue - Compile all tables that are in service query datasouce and ax* classes related to the services.
2) Fix error(s).
3) Refresh AIFservices as mentioned above.

Cheers!

Wednesday, June 3, 2015

Wildcard search in Dynamics AX



If you have to add functionality similar to wildcard like operator.

Select * from VendTable where VendTable.Name is like ‘%Vendor XYZ%’

You can use static functions SysQuery::valueLike and SysQuery::ValueLikeAfter.I used these functions in datasource ExecuteQuery() method

QueryBuildRange vendorFilter = SysQuery::findOrCreateRange(PGDFileline_q.dataSourceTable(tablenum(vendTable)),fieldNum(VendTable,AccountNum));

if (vendTxt.text()!="")
{
vendorFilter.value(SysQuery::valueLikeAfter(vendTxt.text()));
}
else
{
vendorFilter.value(SysQuery::valueUnlimited());
}

super();

Tuesday, June 2, 2015

Dynamics AX 2012: Delete operating unit

AX throws an error "This organisation participates in one or more hierarchies and cannot be deleted" when you try to delete an operating unit if it is used in one or more organizational hierarchy.

Here is a way to delete operating unit,

1) Table: OmOperatingUnit - get recid using name or name alias(this recid will be used in next three steps).

2) Table: DimensionAttributeValue -> Field: EntityInstance -> search recid in this field and delete record.

3) Table: OMHierarchyRelationship -> Field: ChildOrganisation ->  search recid in this field and delete record.

4) Table: OMOperatingUnit -> Field: recid -> search recid and delete record.