Contents tagged with Acumatica

  • Generic template methods in Acumatica

    Hello everybody,

    today I want to write a few words about Generic template methods in Acumatica. 

    In Acumatica there is such a greate feature as convention over configuration. For example if you want to add reaction in Acumatica on changing the field Description of SOOrder you may do something like this:

    protected void SOOrder_OrderDesc_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)

    {

    }

    and also it's relatively convenient, but inside of that method you'll need to make some casting operations. For quite a long time Acumatica allows to have new format with usage of underscore:

    protected void _(Events.FieldUpdated<SOOrder, SOOrder.orderDesc> e)

    {

        

    }

    And take a note of … more

  • How to assign random values to each row in SQL for Acumatica

    Hello everybody,

    recently during testing of some logic for me it was necessary to assign some random values to table VendorPart in Acumatica. In order to achieve it, I've created such a script:

    update VendorPart set NetPrice = (ABS(CHECKSUM(NEWID()))% 3000.25 + 1.1 + 1), ListPrice= (ABS(CHECKSUM(NEWID()))% 3000.25 + 1.1 + 1)

    where NetPrice = 0 and ListPrice = 0

    of course such a query will not satisfy all requirements for random numbers generator, but in scope of my business scenario it was better then assign the same value to both columns.

    Summary

    If you want to have some diversity in digits for your values, use NEWID function for assigning values. more

  • Import data in Acumatica

    To import data (Customers for instance) from .xlsx format we need to make 3 actions:           

    Create Data Provider

    Create an Import Scenario

    Make an Import by Scenario

    1: First of all, before we will start do all those steps, we need to have .xlsx file with customers and such fields at least on the first row as a heading row:

    After that when we’ve checked Customers.xlsx file, click on the menu button and choose Integration tab.

       

    Afterwards on the Profiles subheading click Data Providers

    In the *Name field type the name of the future Data Provider to/from Excel format (Import/Export Customers to Excel) and in the next field  - * Provider Type: choose … more

  • Export data from Acumatica

    Hello everybody,

    I want to describe how to export data from Acumatica. 

    To export data (Customers for instance) to .xlsx format output we need to make 3 actions:

    Create a Data Provider

    Create an Export Scenario

    Make an Export by Scenario

    1. First of all, before we will start do all those steps, we need to create .xlsx file with such fields at least on the first row as a heading row:

    After that when we’ve created Customers.xlsx file, click on the menu button and choose Integration tab.

    Afterwards on the Profiles subheading click Data Providers:

    In the *Name field type the name of the future Data Provider to Excel format (Import/Export Customers to Excel) and in … more

  • Acumatica Sequence of Events

    Hello everybody,

    today I want to leave a picture, which shows sequence of events in Acumatica depending from happening scenario. 

    Sometime I'm getting questions from people like this: why after update of record I don't have my FieldDefaulting executed?

    Or why deletion of record doesn't trigger my RowUpdated event?

    Or why Save doesn't initiate RowInserting event and so on. 

    If you take a look on the picture you'll be able to notice that those questions easily addressed. 

    That picture shows that during update, you have executed FieldUpdating, FieldVerifying and FieldUpdated executed. But you will not get FieldDefaulting executed, 

    because it was executed before in Insert event. 

    Below … more

  • How to speed up database of Acumatica with RAID-10

    Hello everybody,

    today I want to leave a note regarding performance of database of Acumatica. Once I had request of possible speeding up of operations with DB.

    The most practical advice which you will hear will be put log files on one SSD drive, and mdf file on another SSD drive.

    But what to do, if that is not enough? What are other ways of speeding up DB in itself.

    As the answer I'd suggest to consider RAID-10 technology.

    Below goes simplest explanation of RAID-10 explanation and how it works:

    This picture says following:

    File MyFileN1.txt will be stored in four hard drives. Two times on RAID-1 array and two times on RAID-1 array, and splitting of it will be done through RAID-0 … more

  • Property from CROpportunity is not loaded

    Hello everybody,

    today I want to leave short note on issue with CROpportunity DAC class.

    For quite a few times I've noticed that someone adds field to CROpportunity, but later notices that field is lost either on moment of loading from database, or lost during persisting record to database.

    Reason for such weirdness is that starting from some Acumatica version CROpportunity got following declaration:

    [System.SerializableAttribute()]

    [PXCacheName(Messages.Opportunity)]

    [PXPrimaryGraph(typeof(OpportunityMaint))]

    [CREmailContactsView(typeof(Select2<Contact,

    LeftJoin<BAccount, On<BAccount.bAccountID, Equal<Contact.bAccountID>>>,

    Where2<Where<Optional<CROpportunity.bAccountID>, … more

  • LastModifiedDateTime has wrong datetime information

    Hello everybody,

    today I want to share interesting use case which raised recently when dealt with syncrhonization of records between Magento and Acumatica.

    I had following declaration:

    #region LastModifiedDateTime

    [PXDBDateAndTime()]

    [PXUIField(DisplayName = "Last Modified Date Time")]

    public virtual DateTime? LastModifiedDateTime { get; set; }

    public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }

    #endregion

    and for my disappointment as well as disappointment of Magento developers we had to add some hours shift to each call, in order to filter out properly by Last modified Date time.

    One of the solutions was to add one more flag to … more

  • New SQL Server 2016 features to use in Acumatica

    Hello everybody,

    today I want to write about new additions for SQL Server T-SQL language, which are there starting from 2016. It is create or alter syntax.

    In the past, if you've made some custom SQL view, it was needed to have constructions like this ( pseudo code ):

    if view ( stored procedure, function, trigger ) exists

         create view ( stored procedure, function, trigger )

    else

       alter view ( stored procedure, function, trigger )

    But startring from 2016 SP1 you can use following syntax ( pseudo code ):

    Create or alter view ( stored procedure, function, trigger ).

    Or in code form it may look like this:

    create or alter procedure yourProcedure

    as

    begin

     print (1)

    end;

    go … more

  • SelectFrom for usage in View.Select

    Hello everybody,

    I want to leave a short note on how to use SelectFrom for legacy code, and pass it in View.Select for Acumatica newer versions. 

    var cmd = new SelectFrom<PartsCatalog>.

        InnerJoin<INSiteStatus>.On<Use<PartsCatalog.inventoryID>.AsInt.IsEqual<Use<INSiteStatus.inventoryID>.AsInt>>.View(this);

    var s = (currentFilter.PageNbr ?? 0) * (currentFilter.PageSize ?? 0);

    int startRow = s > 0 ? s : PXView.StartRow;

    int totalRows = 0;

    int maxRows = (currentFilter.PageSize ?? 0) == 0 ? PXView.MaximumRows : currentFilter.PageSize ?? 0;

    var list = cmd.View.Select(new[] { currentFilter }, null, PXView.Searches,

        PXView.SortColumns, PXView.Descendings, PXView.Filters, ref  … more

  • How to overrde Authorize CC Payment Action in Acumatica

    Hello everybody,

    as it was mentioned in one of my previous blog posts, regarding overriding base actions of Acumatica graphs, family of graph extensions grows and grows. 

    Today I want to share one more code snipped whic you can use for extending modifing Acumatica actions. Below goes code fragment, which you can use for modification of Authorize CC Payment:

    public class PaymentTransactionExt : PXGraphExtension<PaymentTransaction, SOOrderEntry>

    {

        [PXOverride]

        public virtual IEnumerable AuthorizeCCPayment(PXAdapter adapter, Func<PXAdapter, IEnumerable> baseFunc)

        {

            

            var result = baseFunc(adapter);

            

            return result;

        }

    }

    Of what I … more

  • How to override ShopRates action in Sales Orders form

    Hello everybody,

    today I want to leave a short post on how to override Shop rates Action in Acumatica. 

    I mean this button:

    Below goes C# code, with which you can achieve it:

    public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry.CarrierRates, SOOrderEntry>

    {

        [PXOverride()]

        public virtual IEnumerable ShopRates(PXAdapter adapter, Func<PXAdapter, IEnumerable> baseMethod)

        {

            //your code here

            var retVal = baseMethod?.Invoke(adapter);

            //and possibly here

            return retVal;

        }

    }

    As you can see from the code, life in Acumatica becomes more complex, and if in the past you've used to override directly your actions, now you'll need … more

  • PXLongOperation cleans everything. How to avoid?

    Hello everybody,

    today I want to write a few words about interesting behavior of PXLongOperation.StartOperation in Acumatica.

    On the glance that looks pretty simple and straightforward. You have something processing of which will take a long time? Use PXLongOperation.StartOperation. So imagine, you extend ARPaymentEntry graph like this:

    public PXAction<ARPayment> StartOperation;

    [PXProcessButton]

    [PXUIField(DisplayName = "Some long running operation")]

    protected virtual IEnumerable startOperation(PXAdapter adapter)

    {

       

       PXLongOperation.StartOperation(Base, () => SomeLongRunningOperation(Base.Document.Current)); return adapter.Get();

    }

    In this case you may notice … more

  • How to make dynamic List with check boxes in Acumatica

    Hello everybody,

    today I want to share with you a piece of code, with help of which you can get list of all activer order types in Acumatica and also you'll get a chance to select those types with checkbox. Take a look on a screenshot below:

    how to achieve this?

    Code below without description of DAC class gives you this:

    protected virtual void _(Events.FieldSelecting<SetupClass, SetupClass.orderTypes> e)

    {

        if (e.Row == null)

        {

            return;

        }

        var orderTypes = SelectFrom<SOOrderType>.Where<SOOrderType.active.IsEqual<True>>.View.Select(this).Select(a => a.GetItem<SOOrderType>())

            .ToList();

        var allowedValues = orderTypes.Select(a => a.OrderType). … more

  • How to insert VARBINARY data in MS SQL for Acumatica

    Hello everybody,

    sometime it is needed to insert some binary information in one or another table inside of Acumatica. Quite often developers just modify existing record in table UploadFile or UploadFileRevision.

    But I don't like such approach, as it is prone to errors and potentially can harm some of your existing data. That's why I propose to use cast operator of MS SQL. Take a look at following example:

    insert into UploadFileRevision(CompanyID, FileID, FileRevisionID, Data, Size, CreatedByID, CreatedDateTime, CompanyMask) values

    (2, '35b15ad7-b5c3-4a19-aa77-3a24c046d689', 1, 

    CAST('wahid' AS VARBINARY(MAX)),

    4, 

    'B5344897-037E-4D58-B5C3 … more

  • How to imitate click on Confirm shipment in Acumatica

    Hello everybody,

    Today I want to describe how to imiate click on menu item "Confirm shipment" in Acumatica. 

    Probably your first guess will be just call method ConfirmShiment of graph SOShipmentEntry. But for now Acumatica team has another advice in order to call this action. Instead of calling method ConfirmShipment you'll need to have a bit more steps.

    Code sample below demonstrates those necessary steps:

    SOShipmentEntry shipmentGraph = PXGraph.CreateInstance<SOShipmentEntry>(); //Create instance of Graph

    PXAutomation.CompleteSimple(shipmentGraph.Document.View);

    PXAdapter adapter2 = new PXAdapter(new DummyView(shipmentGraph, shipmentGraph.Document.View.BqlSelect,

     new  … more

  • Pagination in custom inquiry

    Hello everybody,

    today I want to share with everybody, and with myself code fragment, that allows to achieve pagination in custom inquiry pages. 

    Take a look on the code below:

      public class YourGraphInquiry : PXGraph<YourGraphInquiry>

      {

        public PXCancel<YourDACFilter> Cancel;

            public PXFilter<YourDACFilter> Filter;

            [PXFilterable]

            public PXSelect<YourDACDetails,

                Where2<

                    Where<YourDACDetails.Someid, Equal<Current<YourDACFilter.SomeID>>, 

                        Or<Current<YourDACFilter.SomeID>, IsNull>>,

                    And<

                        Where<YourDACDetails.Somepartid, Equal<Current<YourDACFilter.SomePartId>>, 

         … more

  • Three states of fields in Acumatica

    Hello everybody,

    today I want to write a short note on three states of fields existing in Acumatica:

    Exists but is empty

    Exist and have value

    Has null

    If to speak about string, it can exist like this:

     

    Some value

     

    Do you see difference between 1 and 3? Not easy. As usually developers of C#, show this difference like this:

    ""

    "Some Value"

    null

    And following screenshot with explanation shows how it works in case of SOAP contracts:

    so, while you make integration, keep that in mind more

  • New functions for redirect in Acumatica

    Hello everybody,

    today I want to say few words about new functions for redirect in Acumatica, and particularly about class PXRedirectHelper. 

    Classical approach from T200/T300 manual may look like this:

    var currentCse = Cases.Current;

    if(currentCse == null)

    return;

    var graph = PXGraph.CreateInstance<CRCaseMaint>();

    graph.Case.Current = graph.Case.Search<CRCase.caseCD>(currentCse.CaseCD);

    if (graph.Case.Current != null)

    {

    throw new PXRedirectRequiredException(graph, true, "Case details");

    }

    But with new function all of those lines can be simplified to this:

    PXRedirectHelper.TryRedirect(Cases.Cache, Cases.Current, "Edit case", PXRedirectHelper.WindowMode.NewWindow); … more

  • Simplest cachinng explanation

    Hello everybody,

    today I want to give one more explanation of how to use caching and slots for caching purposes. Also there are plenty of articles on the subject,  I want to give one more with simplest recipe. So, if you need to cache something, you'll need to follow this procedure:

    declare you class as something that inherits IPrefetchable

    Create some placeholder in your class for storing items in the cache

    Implement Prefetch

    Implement GetSlot

    Take a look on the code below, how it can be done:

    public class ArTranFetcher : IPrefetchable

    {

    private List<ARTran> _arTranList = new List<ARTran>();

    public void Prefetch()

    {

    _configurableList = new List<ARTran>(); … more