Blog

Here I document some issues for searching of which I spent more then 15 minutes

  • 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

  • Comments TODO and HACK in C#

    Hello everybody,

    today I want to leave one more note, which you can use for boosting your productivity.

    Imagine following scenario. On the meeting with customer you've got some list of to do points. You have them on your email. You've made some research, and found that you need to make changes to 5 C# files. How not to forget about all of those files?

    On rescue comes two comments in C#:

    TODO

    HACK

    Leave those comments in your 5 files -> save all files -> Open Task List, and you'll see something like this:

    As you can see from presented screenshot, after you leave TODO or HACK comments in 5 C# files, you'll be in perfect position of usage of code.

    What is even more interesting, … 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

  • Database of Acumatica is in Recovery Pending condition

    Hello everybody,

    recently I've got interesting situation, when my database for Acumatica developed turned to be in Pending condtion. In order to deal with it, I've executed following SQL:

    ALTER DATABASE YourDatabase SET EMERGENCY;GOALTER DATABASE YourDatabase set single_userGODBCC CHECKDB (YourDatabase, REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS;GO ALTER DATABASE YourDatabase set multi_userGO

    and my database turned back to normal.

    Update on 10/08/2019

    declare @dbName nvarchar(50);

    set @dbName = 'yourDatabase';

    exec( 'ALTER DATABASE' +@dbName  + ' SET EMERGENCY;')

    exec ('ALTER DATABASE ' + @dbName + '  set single_user')

    exec ('DBCC CHECKDB (' + @dbName + ' , REPAIR_ … 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

General information

Greetings to everybody stopping at my blog. Purpose of this web site is to be google of my brain. Everything I found useful, or of possible beneficial for usage in future I've save here at this blog

Contact information

If you want to contact me more on any subject printed at this web stie, you can email me: zaljur1989(at)gmail.com

Job information

If to speak in general, I'm developer. For now I work as team lead in company GlobalLogic.