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.

PXDataBase.Update in Acumatica

Hello everybody,

today I want to note how to use PXDataBase.Update in Acumatica. 

Two use-cases.

1. Imagine, you need to set APSubID = 80 in APRegister with APAccountID = 5:

you can use the following:

PXDatabase.Update<APRegister>(new PXDataFieldAssign<APRegister.aPSubID>(80),

new PXDataFieldRestrict<APRegister.aPAccountID>(5),

new PXDataFieldRestrict("DeletedDatabaseRecord"PXDbType.Bit, false));

2. Set DocBal = 80 and DocDesc = “blah blah blah”  in table APRegister with APAccountID = 5 and APSubID = 80:

PXDatabase.Update<APRegister>(new PXDataFieldAssign<APRegister.docBal>(80),

new PXDataFieldAssign<APRegister.docDesc>("blah blah blah"),

new PXDataFieldRestrict<APRegister.aPAccountID>(5),

new PXDataFieldRestrict<APRegister.aPSubID>(80),

new PXDataFieldRestrict("DeletedDatabaseRecord"PXDbType.Bit, false));

From code, which is displayed above you can see, that for assigning values you mention PXDataFieldAssign. PXDataFieldAssign<APRegister.docDesc>("blah blah blah") will be converted into APRegister.docDesc = "blah blah blah"

For setting statement where you can use PXDataFieldRestrict. PXDataFieldRestrict<APRegister.aPAccountID>(5) will be added to Where as APRegister.aPAccountID = 5

web.config Timeout Connection timeout

Hello everybody,

Today I want to note web.config properties, which took for me some time to discover. It is possible to add two options in connection string of web.config.

1. Timeout=60

2. Connect Timeout=300

What is difference between those two parameters?

The first one set for how long your code at db will be executed. The second one sets for how long your code will wait for result.

How to block column in Acumatica grid or one value in column

Hello,

I want to share with you how to block some columns in Acumatica.

You can do it with the PXUIFieldAttribute.SetEnabled method.

Let's say you have DAC PRTran with column earningType and values of PRTran you get from PaySlipDetails view. Then you can block whole column with the following call:

PXUIFieldAttribute.SetEnabled<PRTran.earningType>(PaySlipDetails.Cache, null, isEnabled);

Another question which sometime appears is how to block single record value in column.

The solution is the following:

row = .... here goes your logic which will get PRTran for which you need to make blocking

PXUIFieldAttribute.SetEnabled<PRTran.earningType>(PaySlipDetails.Cache,  row, false);

Current items in View

Hello everybody,

today I want to share with everybody how to find all items in view in Acumatica.

Suppose you have View declared in the following way:

public PXSelectJoin<PRPayrollDetails,

InnerJoin<EPEmployee, On<EPEmployee.bAccountID, Equal<PRPayrollDetails.employeeID>>,

InnerJoin<PRPayroll, On<PRPayroll.refNbr, Equal<Current<PRPayrollDetails.payrollRefNbr>>>,

LeftJoin<APInvoice, On<APInvoice.refNbr, Equal<PRPayrollDetails.aPRefNbr>, And<APInvoice.docType, Equal<PRPayrollDetails.aPDocType>>>>>>,

Where<PRPayrollDetails.payrollRefNbr, Equal<Current<PRPayroll.refNbr>>>, OrderBy<Asc<PRPayrollDetails.description>>> PayRollsDetails;

 

and now you made some changes to that view in one of your functions. How to get current situation of view?

If you answered PayRollsDetails.Cache.Cached then you are wrong. You should get them as PayRollsDetails.Select() and only in that way. Then you'll get current situation with items in grid

An object reference is required for the non-static field, method, or property PX.Data.PXSelectBase Acumatica DAC Select in Acumatica

Hello everybody,

today I want to share how to fight with error like 

Error 22 An object reference is required for the non-static field, method, or property 'PX.Data.PXSelectBase<Acumatica DAC>.Select(params object[])' bla bla bla

As usually it means that you try to use this in selector of Extension class. Just replace this at Base or Base2 and your problem will go away.

for example 

CR.Location customerLoc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, 

                            And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(this, customer.BAccountID, customer.DefLocationID);

should be 

CR.Location customerLoc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, 

                            And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(Base, customer.BAccountID, customer.DefLocationID);

and your code will be compiled again