Make grid to have all screen

Hello everybody,

today I want to share how to make grid item to feet all container. For this purpose you just can use property AutoSize. It makes grid to feet entire area of parent container

Create graph instance

Hello everybody,

today I want to notice how to create graph. There are two ways:

 

PXGraph.CreateInstance<BaseBLC>();

PXGraph.CreateInstance(typeof(BaseBLC));

 

If you want to get extention class, from base class, you can use following function:

GraphInstance.GetExtension<ExtentionClass>();

Fix at least one column in the Selected area and controlling set of selected columns in Acumatica

Hello everybody,

today  I want to share tricks related to Acumatica grids:

1.       How to fix at least one column in the Selected area so users will not be able to move it to the Available? All our custom pages have grids which can be moved.

------ You need to utilize PXGridColumn’s  AllowShowHide property set to False for not allowing user to hide for at least key column/s.

2.       How to control the default set of Selected columns for the grid so only the particular columns will be shown in the grid by default, and the rest of columns can be added by the user if necessary?

------- Grid Columns created for DAC fields marked not visible will be shown as Available column

 

Practical value of such fixing is that user can remove all columns, and if he does so, then grid disappear, and you'll need to dig in db in order to resurect grid on page. 

Debug ExecuteSelect in Extentsion graph of Acumatica

Hello everybody,

today I want to share how to debug method ExecuteSelect from Base in extension class:

public delegate IEnumerable exSelectDelegate(string viewName, 
object[] parameters,

object[] searches, string[] sortcolumns, bool[] descendings,
PXFilterRow[] filters, ref int startRow, int maximumRows, ref int totalRows); [PXOverride] public IEnumerable ExecuteSelect(string viewName, object[] parameters,
object[] searches, string[]
sortcolumns, bool[] descendings,
PXFilterRow[] filters, ref int startRow, int maximumRows, ref int totalRows,
exSelectDelegate f ) { IEnumerable result = null; try { result = f(viewName, parameters, searches, sortcolumns, descendings, filters, ref startRow, maximumRows, ref totalRows); } catch (Exception ex) { // analyze exception in some way } return result; }

How to deal with cases when Decimal is not enough

Hello everybody,

today I want to drop a note about cases when you need high precision, and C# type decimal is not enough for your needs.

I discovered for myself GNU MP library, which has also wrapper in C#. 

Amongh feautures which this library proposes are the following:

1. High number precision, which is limited only by available memory.

2. Rish set of operators

Neural Networks teaching

Hello everybody,

today I watched vidoe of Dr. James McCaffrey about traing neural netwoks. 

So, few interesting details, which was useful for me. 

1. As usually it is more then enough one hidden layer. 

2. Imagine, that you need to feed into your neural network some data. Let's say Age, income, sex, religion. For data normalization it is good to use not big numbers.

For example for Income which is around 51000 it's good to give to network 5.1 and not 51000.

For sex passing into NN it's good to use gues what? If you have an idea 0 and one, you are wrong. It's good to pass -1 and 1.

And for classfication like if you have input for example 3 different categories, the best way to pass not values like 1, 2, 3, but to pass three inputs, and pass at them 100, 010 or 001. For example if you need to code Christian, Muslim, Buddhist, you'll pass 100 for Christian, 010 for Muslim, 001 for Buddhist.

3. Four most common activation functions:

  a. logistic sigmoid

  b. hyperbolic tangent

  c. Heaviside step

  d. Softmax

4. Training algorithms for neural networks:

  a. back-propogation

  b. genetic algorithm

  c. particle swarm optimization

RowDefaulting and copy/paste in Acumatica or copy paste mode in acumatica

Hello everybody,

recently I had the following situation. 

According to business logic, I created RowDefaulting. And it worked great. Then business analyst decided to check copy/paste functionality of Acumatica, and you know what? He discovered that copy/paste is broken. After investigation I discovered that it was due to RowDefaulting event.  For me it meant the following, I need to turn off RowDefaulting after copy/paste. 

After usage of reflector, I noticed interesting property  IsCopyPasteContext in the graph. 

So I modified function RowDefaulting.

private void RowDefaulting(PXGraph graph)

{

      if( !graph.IsCopyPasteContext )

          {

                    //do some row defaulting logic.

          }

}

 

Hope you enjoyed this tip

Custom Selector in Acumatica

Greetings to everybody,

today I want to document how to make selector in Acumatica. 

I had the following use case:

1. Acumatica dropdown, which can have three values ( for example a, b, c) .
 
1.1 In case if user select option a, I need to show in PXSelector values from Table A with some filtering condition.
1.2 In case if user select option b, I need to show in PXSelector values from Table  B with another filtering condition
1.3 In case if user select option c, I need to show in PXSelector value from Table C with another filtering condition

Due to the fact, that PXSelector can work only with one DAC, the only way to solve it was implementing custom selector which inherits from PXCustomSelectorAttribute class.

In order to do this, I made the following code:

public class SelectorCustomerContractAttribute : PXCustomSelectorAttribute
    {
        private Type selectorField;
        private Type contractFld;

        public SelectorCustomerContractAttribute(Type selectorField, Type contractField)
            : base(typeof(DRDocumentRecord.refNbr))
        {
            if (selectorField == null)
                throw new ArgumentNullException("selectorField");

            if (contractField == null)
                throw new ArgumentNullException("contractField");


            if (BqlCommand.GetItemType(selectorField).Name != BqlCommand.GetItemType(selectorField).Name)
            {
                throw new ArgumentException(string.Format("moduleField and docTypeField must be of the same declaring type. {0} vs {1}",
                    BqlCommand.GetItemType(selectorField).Name, BqlCommand.GetItemType(selectorField).Name));
            }

            this.selectorField = selectorField;
            contractFld = contractField;
        }

        public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {           
        }

        protected virtual IEnumerable GetRecords()
        {
            var cache = this._Graph.Caches[BqlCommand.GetItemType(selectorField)];
            var cbs = (ContractBillingSchedule) cache.Current;
            cache = this._Graph.Caches[BqlCommand.GetItemType(contractFld)];
            var contract = (Contract) cache.Current;
            var result = new List<int>();

            if (cbs.BillTo == "M")
            {
                result.Add(1);
            }

            if (cbs.BillTo == "P")
            {
                result.Add(2);
            }
            if (cbs.BillTo == "S")
            {
                result.Add(3);
            }
            result.Add(4);
            return result;
        }
    }

NB. List is not feeting for result, but if you change it to something else, you can easily to achieve what you want. 

Usage of the selector can be like this:

public class ContractBillingScheduleExt : PXCacheExtension<ContractBillingSchedule>
    {
        #region UsrCustomerContact
        public abstract class usrCustomerContact : IBqlField, IBqlOperand
        {
        }
        [PXDBInt]
        [SelectorCustomerContract(typeof(ContractBillingSchedule.billTo), typeof(Contract.contractID))]
        [PXUIField(DisplayName = "Customer Contact", Visibility = PXUIVisibility.SelectorVisible)]
        public virtual int? UsrCustomerContact { get; set; }
        #endregion
        
    }

enjoy if you need

Acumatica Cache inserted updated objects

Hello everybody,

today I want to share one simple technic of how to filter inserted items in cache from other objects. I discovered it with reflector, while diffing in code of APInvoiceEntry. 

Here it is: 

Adjustments.Cache.Inserted - this item will give you which items were inserted in view Adjustments. 

Another interesting details was updated:

Adjustments.Cache.Updated

will give you updated items in cache.

And of course deleted: 

Adjustments.Cache.Deleted

SetValueExt and SetDefaultExt in Acumatica

Hello everybody,

today I want to share with you information about two functions:

SetValueExt and SetDefaultExt. 

Names of them are pretty self-explanatory, which means SetValueExt assigns specific value to field and SeDefaultExt assings default value to a field. But SetValueExt  method raises the field-level events for the data field as when a data record is updated. The SetDefaultExt<>()method of the cache to assign the default value a field. The method raises the field-level events for the data field as when a data record is inserted.