Contents tagged with Acumatica

  • Addition to PXDatabase.Update in Acumatica

    Hello everybody,

    today I want to share a new feature for me in Acumatica from code standpoint. 

    So, suppose that you want to update some column in Acumatica database, but you want to avoid graph creation, loading necessary fields, and all that you need to do is just update column. For example over adding some value.

    You can't achieve it with simple call to

    PXDatabase.Update<>()

    Or if you can, then let me know, because I didn't find the way how to do it. 

    But instead I found another new method in Acumatica which is named PXUpdate.

    For example you can use this method for adding to each email in table contact value ".someaddition"

    PXUpdate<Set<Contact.eMail, Add<Contact.eMail,  … more

  • How to get companyID in Acumatica 2

    Hello everybody,

    today I want to leave another post related to getting Acumatica. There is one more way of gettinc current company id. For this purpose you can use class of Acuamtica named SharedFunctions.

    It has plenty of interesting staff, as well as getting Current company id. Take a look on it:

    var companyId = SharedFunctions.GetCurrentCompanyId();

    more

  • How to interfere with Acumatica after publish of customization

    Hello everybody,

    today I want to tell you about interesting class in Acumatica: CustomizationPlugin. Take a look on how reflector shows it's source code:

    namespace Customization

    {

      public abstract class CustomizationPlugin

      {

        public virtual void OnPublished()

        {

        }

        public virtual void UpdateDatabase()

        {

        }

        public void WriteLog(string msg)

        {

          CstPublishLog.WriteLog(msg);

        }

      }

    }

    As you can see, this class has three methods:

    OnPublished

    UpdateDatabase

    WriteLog

    Each of those events allows you to update Acumatica after some events happening. For example after publish, on stage of updating database, and also you can use it … more

  • How to override properly CreatePaymentProc method of SOOrderEntry graph in Acumatica

    Hello everybody,

    today I want to leave short note on how to override and call CreatePaymentProc method of Acumatica which I discovered today with Naveen from Kensium.

    My favorite way of overriding methods in Acuamtica with usage of Action and passing there parameters doesn't work. That is because Acumatica uses in method CreatePaymentProc out modifier. Due to this, delegate declaration is needed. 

    After some efforts and refactorings we found following code that is working:

    public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>

    {

        public delegate void CreatePaymentBase(SOOrder order, out PXGraph target, string paymentType);

        [PXOverride]

        public virtual void  … more

  • How to increase length of Customer id column

    Hello everybody,

    today I want to describe interesting case. Recently I was asked to increase length of Customer ID at page AR303000.

    As usually such tasks can be achieved via creating extension to DAC class with setting new length, 

    and with SQL statement that increases length of column. But that is not the case with Customer ID. That is because

    Customer ID is Segmented Selector. And everything related to segmented selectors should be managed 

    at page Segmented Keys page ( CS202000 ). All that is needed to be done is increasing the Length field of segmented keys.

    Other approaches can lead to corruption of segmented keys. Especially if you decide to do it in database with DB scripts.  … more

  • How to shrink database of Acumatica with rebuilding of

    Hello everybody,

    today I want to leave another portion of SQL Server optimization for Acumatica database. In case if your db become huge, and you want to make it smaller, you can try following SQL code:

    DECLARE @Table NVARCHAR(128)  

    DECLARE @Database NVARCHAR(128)

    DECLARE @Command NVARCHAR(500)

    PRINT N'Shrinking database files'

    DBCC SHRINKDATABASE(0)

    PRINT N'Rebuilding all indexes'

    SET @Database = DB_NAME()

    SET @Command = 'DECLARE TableCursor CURSOR FOR SELECT ''['' + TABLE_CATALOG + ''].['' + TABLE_SCHEMA + ''].['' + 

        TABLE_NAME + '']'' as TableName FROM [' + @Database + '].INFORMATION_SCHEMA.TABLES 

        WHERE TABLE_TYPE = ''BASE TABLE'''   

    EXEC (@Command)  

    OPEN  … more

  • How to find sizes of tables in Acumatica

    Hello everybody,

    today I want to share with you SQL statement that may help you to find sizes of tables occupied by Acumatica. It goes below:

    SELECT 

        t.NAME AS TableName,

        s.Name AS SchemaName,

        p.rows AS RowCounts,

        SUM(a.total_pages) * 8 AS TotalSpaceKB, 

        CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceMB,

        CAST(ROUND(((SUM(a.total_pages) * 8) / 1024.00 / 1024.00), 2) AS NUMERIC(36, 2)) AS TotalSpaceGB,

        SUM(a.used_pages) * 8 AS UsedSpaceKB, 

        CAST(ROUND(((SUM(a.used_pages) * 8) / 1024.00), 2) AS NUMERIC(36, 2)) AS UsedSpaceMB, 

        (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB,

        CAST(ROUND(((SUM( … more

  • How to make calculated field available in Generic Inquiry screen of Acumatica and Starship

    Hello everybody,

    today I want to describe interesting case. 

    I was asked to add on Acumatica screen Date field, which calculates according to some business logic rules. Task was pretty simple initially to do, so I've jumped, and added that field like this:

    public abstract class usrExpectedByDate : IBqlField

    {

    }

    [PXDBDate()]

    [PXUIField(DisplayName = "Expect Date", IsReadOnly = true)]

    [PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]

    public virtual DateTime? UsrExpectedByDate { get; set; }

    I provided this customization to customer and had expectation that I can enjoy from my life. 

    But with time, customer notified me, that shiping didn't work as expected. Why, because in … more

  • How to add validation to Create shipment and confirm shipment in Acumatica

    Hello everybody,

    today I want to write a few words on my latest time spending in Acumatica. Recently I was asked to add additional validations to actions Create shipment:

    and Confirm Shipment:

    Idea was the following, if user clicks on Create shipment action or at Confirm Shipment action, some function should be executed which throws exception and prevents Creation/confirmation of shipment if some conditions are not meet. 

    At first glance task was trivial. I supposed that all that will be needed, just override method Create Shipment of SOOrderEntry and Cofirm Shipment of SOShipmentEntry. And jumped right to the code. 

    In order to modify behavior of those two methods, I've created … more

  • One more description on how to modify behavior of Sales Orders screen in Acumatica

    Hello everybody,

    today I want to present a bit differnt code sample on how to append to behavior of Actions menu items of Sales Orders screen. 

    Quite often there are tasks like add something before ( preprocessing ) or after some menu item action was executed. Once I've described it alredy here, but just want to give another example with usage of Func.

    Take a look on following code sample:

    [PXOverride]

    public IEnumerable Action(PXAdapter adapter, int? actionID, DateTime? shipDate, String siteCD, String operation, 

        String ActionName, 

        Func<PXAdapter, int?, DateTime?, string, string, string, IEnumerable> baseMethod)

    {}

    as you can see, it's very similar to previous post, just … more

  • How to modify Process Shipments screen in Acumatica

    Hello everybody,

    recently I was asked to modify behavior of Process shipments screen in Acumatica. Issue was the following: in case if one of the rows on Process shipments generated error, it was needed to show on the status of processing.

    Default behavior was like showed on the screenshot:

    as you can see on the screenshot, despite errors were generated on the row level, whole status of processing is fine ( green in the top ).

    Of course for my QA such kind of behavior is weird and he asked me to fix it. 

    Such behavior happens because Process shipments screen ( SO503000 ) uses PXProcessing.SetProcessTarget() to set the processing delegate which doesn't care at all about errors in the … more

  • Improve performance of grouping operations in Acumatica

    Hello everybody,

    today I want to write a note about interesting case I faced recently. 

    I was asked to load from Acumatica database Sales orders joined with PO Receipts by inventory, but I had one issue. It was needed to join only by latest PO Receipt, not by allo PO Receipts. In other words it was needed to take only one element of each group. 

    As usually such kind of implementation is done with help of overloading delegate, which loads all data from SQL Server into memory and then does grouping operaions in memory. Such approach is workable on relatively small cases, but if database of customer 

    is around 130 Gb, then we faced timeout issue. 

    How to deal with it. 

    After some trial … more

  • How to notify about errors on Processing screens that are made through Automation schedules

    Hello everybody,

    today I want to leave a short notice on how to send a message from your graph for cases, when your graph is used in processing screen which is implemented through Automation steps. For this purpose you can use new property of PXAdapter class. It has property 

    MassProcess. In case if your graph will be executed from processing screen that property will be set to true. Then you'll get a chance to notify processing screen about error with help of SetError message. In that case in your graph you can write something like this:

    var currentSoOrder = currentSoOrderBoxed.GetItem<SOOrder>();

    string errorMessage = string.Format(WorkFlowMessages.creditLimitExceededTemplate,  … more

  • NullIf and IsNull in Acumatica

    Hello everybody,

    recently I debugged code of Acumatica, and found following expression:

    [PXFormula(typeof (Switch<Case<Where<Add<SOOrder.releasedCntr, SOOrder.billedCntr>, Equal<PX.Objects.CS.int0>>, SOOrder.curyOrderTotal, Case<Where<Current<SOSetup.freightAllocation>, Equal<FreightAllocationList.prorate>>, Add<SOOrder.curyUnbilledOrderTotal, IsNull<Mult<Div<SOOrder.curyUnbilledOrderTotal, NullIf<SOOrder.curyLineTotal, decimal0>>, SOOrder.curyFreightTot>, decimal0>>>>, SOOrder.curyUnbilledOrderTotal>))]

    I always got scared when I see such kind of expressions. I have a feeling that it was written by somebody who can easily pass zebra puzzle. Unfortunately I'm not such a men. 

    While … more

  • How to allow Deleting of row in RowPersisting method of Acumatica

    Hello everybody,

    today I want to tell interesting behavior of method RowPeristing in Acumatica graphs. Try to guess, after which actions of user that event is getting called? Save ? Yes. Delete? Also yes! Insert? Also yes. 

    If you ask me why? I'll not provide you an anser. But I want to leave a piece of code which describes how to understand which action was called. I'll demonstrate it on sample of SOShipLine, and you'll be able to use it for other DAC classes, with slight modificaitons.

    Here you can see two cases:

    protected void SOShipLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)

    {

        var soShipLine = e.Row as SOShipLine;

        if (sender.GetStatus(soShipLine) ==  … more

  • How to use PXUIVisible in Acumatica

    Hello everybody,

    today I want to leave a short notice on how to use PXUIVisible attribute. I already mentioned that attribute in this article but today just want to give one more example of it's usage.

    Take a look on the following code:

    [PXDBBool()]

    [PXUIField(DisplayName = "Shipment display")]

    [PXUIVisible(typeof(Where<Terms.visibleTo, Equal<TermsVisibleTo.all>, Or<Terms.visibleTo, Equal<TermsVisibleTo.customer>>>))]

    protected void Terms_UsrShipmentDisplay_CacheAttached(PXCache sender)

    {

    }

    As you can see from the example, PXUIvisible expectes from you to get some kind of where condition. Another important detail is that control, from which visibility depends should have … more

  • How to override ExecuteSelect in Acumatica in your graph

    Hello everybody,

    today I want to leave a short notice on how to override ExecuteSelect method in your own graph for debugging purposes. I found following code useful:

    public override IEnumerable ExecuteSelect(string viewName, object[] parameters, object[] searches,  string[] sortcolumns, bool[] descendings, PXFilterRow[] filters,  ref int startRow, int maximumRows, ref int totalRows)

    {

        //Here you can analyze what is coming into your select

        var result = base.ExecuteSelect(viewName, parameters, searches, sortcolumns, descendings,  filters, ref startRow, maximumRows, ref totalRows);

        //And here you can  … more

  • What is Min. Markup, Markup, MSRP in Acumatica

    Hello everybody,

    today I want to leave a note about few abbreviations in Acumatica related to Price/Cost info tab.

    Min. Markup % - percentage. In other words that is minimal addition to price which your company adds to cost of buying of something

    MSRP - manufacturer suggested retail price

    Markup - extra cost added to price. more

  • Default values for inquiry for date in Acumatica

    Hello everybody,

    today I want to leave a short note on Default value for the inquiry screens for Data type. For date you can use following predefined values:

    @WeekStart and @WeekEnd - as name suggests start and the end of Current week

    @MonthStart and @MonthEnd - start and the end of Current Month

    @PeriodStart and @PeriodEnd - start and the end of Current period

    @QuarterStart and @QuarterEnd - start and the end of Current quarter

    @YearStart and @YearEnd - start and the end of Current year

    @Today - today is always today

    I hope this short notice will help you better feed dates into your inquiries.  more

  • How to execute action Email Purchase Order in Acumatica and how create PXAdapter

    Hello everybody,

    today I want to post code sample on how to execute menu item "Email Purchase Order" in Acumatica.

    I mean this fragment of Purchase order screen:

    If you'll try to find the source code of that Action or menu item, you'll be disappointed because you'll not find it. As some other actions, Email Purchase Order is implemented in Acumatica as combination of Automation steps with C# functions.

    Below goes code sample, that allows you to call that method with help of static method:

    public static void SendNotificationForGraph(POOrderEntry graph, POOrder order)

    {

        graph.Clear(PXClearOption.ClearAll);

        graph.Document.Current = graph.Document.Search<POOrder.orderNbr>( … more