Friday, 23 September 2016

Custom Selector Attribute

Hi All,

Today I want to discuss with you a ways to define selectors and data for them.
define selectors and data for them in acumatica
Usually you define selectors like this:
[PXSelector(typeof(Search<Carrier.carrierID>))]

In this case system will automatically select value from database Carrier table and show list of Carrier IDs to user.
In this case you have 2 potential problems:

  • you should have a database table, otherwise you will see an error.
  • There is no way to dynamically change or adjust data that is returned to user
  • You can limited configurations to control selector behavior. 

To solve these problem Acumatica has a Custom Selector attributes:
public class CustomerPriceClassAttribute : PXCustomSelectorAttribute
{
    public CustomerPriceClassAttribute()
        : base(typeof(ARPriceClass.priceClassID))
    {
            this.DescriptionField = typeof(ARPriceClass.description);
    }
    protected virtual IEnumerable GetRecords()
    {
        foreach (ARPriceClass pc in PXSelect<ARPriceClass>.Select(this._Graph))
        {
            yield return pc;
        }
    }

}

In this case you see that you have simple attribute, that is really similar to the attribute for first example. Using GetRecords method you can create a custom BQL querry, select any data you want, apply any filter and return it as a IEnumberble collection.
In the user interface you will see exactly data provided by your custom query.

Monday, 19 September 2016

Make compilation of extension library faster

Hi All,

When you develop customization using Microsoft Visual Studio you may notice that compilation process (if you click F6 or Ctrl+Shift+B) is really long - you may wait for 5-10 minutes.

Usually this happens because system compiles full solution that contains DLL and also Web Site. Site has multiple pages that have aspx markup and must be transformed before compilation. But actually this process is required only for validation purpose and does not require for Acumatica functionality, as ASP.NET will compile page any way one more time when you open it in browser.
You may read more about it here.

So as it is optional compilation you may guess that it can be disabled. Just go to web site property pages and deactivate 2 configurations:

  • Build Web site as part of the solution
  • Before run startup page - no build.

After this your compilation process will take just few seconds instead of minutes. And it is absolutely save for your customization development.

But we still highly recommend you to do one full compilation and validation before releasing of final production version of customization to ensure that there is not errors on final pages.

Have a nice development!

Wednesday, 14 September 2016

Acumatica REST API

HI All,

With Acumatica 6 release you can find (and actually use) new type of API - Rest API.
Acumatica 6 API

Acumatica Rest API is based on Contract based API, so here you have some important points:

  • You need to use existing or custom endpoint be able to send API calls
  • Field and container is available for REST API only if it is defined in contract. But you may extend existing contracts.
  • With REST API you have the same set of commands that you have with Contract Based API.
  • Acumatica uses Json format for transfer data between client and server
  • You still have to maintain session and authentication cookies.

URL:
http://<InstanceName>/entity/<EndpointName>/<EndpointVersion>/<Entity>
Example: http://acumatica.com/entity/Default/6.00.001/StockItem

Ok, lest try to do some examples. Here I will show you how to call Acumatica REST commands from Browser. By using this approach you can easily test functionality and just feel, how does it work.

Thursday, 8 September 2016

Mass Processing using GI

Hi All,

Lets assume that you have multiple records where you need to mass execute some action or update multiple fields to the new value.
From the I100 Acumatica Integration Services Training course you may know that you can do it with Export or Import scenarios. Integration Scenarios are some sort of the small program inside your ERP where you can update multiple fields, calculate depended values, execute actions and so on.
update multiple fields to the new value

But what if you want to have more control on records need to be updated. Some sort of semi-manual mass updating tool? In this case Generic Inquiry Mass Update feature can be more interesting and useful.
update multiple fields to the new value

Lets try to use it.

Monday, 5 September 2016

Disable Discounts Calculation for API Calls

Hi All,

When you creating a multiple AR/SO documents with multiple lines through the API, you may have a nice trick to little-bit optimize system performance.

By default Acumatica business logic is optimized for entering data from UI, so all variables as taxes and discounts must be recalculated on each document line.
But during bulk load you actually can do it just once - before document save.

Here you have extension that will disable automatic discounts calculation if you loading data from API or Integration services.

public class SOOrderEntryExtension : PXGraphExtension<SOOrderEntry>
{
       [PXOverride]
       public virtual void RecalculateDiscounts(PXCache sender,
SOLine line, Action<PXCache, SOLine> del)
       {
              if (!Base.IsImport) del(sender, line);
       }

}

To calculate discounts before saving the record you can manually call RecalculateDiscounts Action from your code. Here is example for Screen-Based API.

List<Command> list = new List<Command>();
list.Add(new Value() { Value = "False", LinkedCommand =
schema.RecalculatePricesAndDiscounts.RecalcUnitPrices });
list.Add(new Value() { Value = "True", LinkedCommand =
schema.RecalculatePricesAndDiscounts.RecalcDiscounts });
list.Add(schema.Actions.ActionRecalculateDiscountsAction);
list.Add(schema.Actions.Save);
list.Add(schema.OrderSummary.OrderNbr);


Content[] result = screen.Submit(list.ToArray());

You can use the similar code for AR invoices as well.

Have a nice integration!

Thursday, 1 September 2016

Custom Integration Services Data Provider

Hi All,

Today I want to share with you one way how you can extend Acumatica data export/import providers or add a new one to integrate with new system.
Acumatica data export/import

To accomplish this task you need some development skills as creation of new provider require some code writing. But you can write this code with any possible way:
  • Visual Studio
  • Acumatica Customization browser
  • Notepad or any compatible application

To create a new provider you need create new class that will implement a IPXSYProvider interface:
public interface IPXSYProvider
{
       string ProviderName { get; }
       string DefaultFileExtension { get; }
       //Parameters
       PXSYParameter[] GetParameters();
       void SetParameters(PXSYParameter[] parameters);
       PXStringState[] GetParametersDefenition(); 
       //Schema
       string[] GetSchemaObjects();
       PXFieldState[] GetSchemaFields(string objectName);
       //Import/Export
       void Export(string objectName, PXSYTable table, bool breakOnError,                                    Action<SyProviderRowResult> callback);
       PXSYTable Import(string objectName, string[] fieldNames, PXSYFilterRow[] filters,                              string lastTimeStamp, PXSYSyncTypes syncType);
}