Solved

DAC Extension fields Default value insert issue

  • 1 August 2022
  • 8 replies
  • 245 views

Userlevel 2
Badge

Hi Everyone,

I’ve Created a new Extension DAC.in this DAC fields , I have to set the PXDefault values but, getting  null reference error when inserting time.

can you please help me on this ,

How to insert the Default value in DB? .

 

this is my Extension DAC fields :-

 

#region WcID

        [WorkCenterIDField(Enabled = false)]

        [PXUIField(DisplayName = "Work Center", Enabled = false)]

        [PXDefault(typeof(Search<AMProdOper.wcID,

          Where<AMProdOper.orderType, Equal<Current<AMClockItem.orderType>>,

              And<AMProdOper.prodOrdID, Equal<Current<AMClockItem.prodOrdID>>,

              And<AMProdOper.operationID, Equal<Current<AMClockItem.operationID>>>>>>))]

        [PXFormula(typeof(Default<AMClockItem.operationID>))]

        [PXReferentialIntegrityCheck]

        public abstract class wcID : PX.Data.BQL.BqlString.Field<wcID> { }

        protected string _WcID;

        public virtual string WcID

        {

            get

            {

                return this._WcID;

            }

            set

            {

                this._WcID = value;

            }

        }

        #endregion

        #region AllowMultiClockEntry

        [PXDBBool]

        [PXUIField(DisplayName = "Allow Clock Entry for Multiple Production Orders", Enabled = false, Visible = false)]

        [PXDefault(typeof(Search<AMWCExt.allowMultiClockEntry,

          Where<AMWC.wcID, Equal<Current<wcID>>>>))]

        [PXFormula(typeof(Default<wcID>))]

        [PXReferentialIntegrityCheck]

        public abstract class allowMultiClockEntry : PX.Data.BQL.BqlBool.Field<allowMultiClockEntry> { }

        protected bool? _AllowMultiClockEntry;

        public virtual bool? AllowMultiClockEntry

        {

            get

            {

                return this._AllowMultiClockEntry;

            }

            set

            {

                this._AllowMultiClockEntry = value;

            }

        }

        #endregion

        #region LaborTimeSeconds

        [PXDBInt]

        [PXUIField(DisplayName = "Labor Time Seconds", Enabled = false, Visible = false)]

        [PXDefault(0)]

        public abstract class laborTimeSeconds : PX.Data.BQL.BqlInt.Field<laborTimeSeconds> { }

        protected int? _LaborTimeSeconds;

        public virtual int? LaborTimeSeconds

        {

            get

            {

                return this._LaborTimeSeconds;

            }

            set

            {

                this._LaborTimeSeconds = value;

            }

        }

        #endregion

icon

Best answer by Marco Villasenor 2 August 2022, 18:51

View original

8 replies

Userlevel 7
Badge +17

Hi, @NageswaraRaoAddanki60  This is related to data issue and the above code provided looks good.

 

Just for verification, you can write this code in the FieldDefaulting event and debug whether you are getting the values or not to identify the issue.

Userlevel 2
Badge

Hi @Naveen Boga I’m Try to debugging this event. debug it is not hitting.

 

 protected void AMClockTran_WcID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)

        {

            var row = (AMClockTran)e.Row;

        }

Userlevel 7
Badge +17

Hi @NageswaraRaoAddanki60  This will invoke only for the first of the document creation and also, make sure that the field should have commitechanges = true in the .aspx page.

Userlevel 2
Badge

Hello @Naveen Boga 

Checking one field value that is AMClockExt.wcID in this value getting null value in FieldDefaulting Event.

 

Userlevel 3
Badge +2

Could you try setting PXDefault to a fixed value to confirm the default value is being set?

Since you use a Search to set the value, it could be setting null because it doesn’t find a value:

[PXDefault(typeof(Search<AMProdOper.wcID,
Where<AMProdOper.orderType, Equal<Current<AMClockItem.orderType>>,
And<AMProdOper.prodOrdID, Equal<Current<AMClockItem.prodOrdID>>,
And<AMProdOper.operationID, Equal<Current<AMClockItem.operationID>>>>>>))]

 

Userlevel 2
Badge

Hi @Marco Villasenor I’m Already Added like you. The Main aim is PXDefault value not Setting to Extension DAC fields, the total Extension DAC fields still showing null values. This DAC fields are not null fields in DB Side. So, whenever inserting data Getting null Exception.

Userlevel 3
Badge +2

I reviewed your code and I found the attributes are in the wrong place. They should be modifying the property getter/setter and not the class. That's why they are not working.

It was easy to miss as @Naveen Boga  and I didn’t see it the first time 😅.

Try it like this:

#region WcID


public abstract class wcID : PX.Data.BQL.BqlString.Field<wcID> { }

[WorkCenterIDField(Enabled = false)]
[PXUIField(DisplayName = "Work Center", Enabled = false)]
[PXDefault(typeof(Search<AMProdOper.wcID,
Where<AMProdOper.orderType, Equal<Current<AMClockItem.orderType>>,

And<AMProdOper.prodOrdID, Equal<Current<AMClockItem.prodOrdID>>,

And<AMProdOper.operationID, Equal<Current<AMClockItem.operationID>>>>>>))]
[PXFormula(typeof(Default<AMClockItem.operationID>))]
[PXReferentialIntegrityCheck]
public virtual string WcID { get; set; }

#endregion

#region AllowMultiClockEntry

public abstract class allowMultiClockEntry : PX.Data.BQL.BqlBool.Field<allowMultiClockEntry> { }

[PXDBBool]
[PXUIField(DisplayName = "Allow Clock Entry for Multiple Production Orders", Enabled = false, Visible = false)]
[PXDefault(typeof(Search<AMWCExt.allowMultiClockEntry,
Where<AMWC.wcID, Equal<Current<wcID>>>>))]
[PXFormula(typeof(Default<wcID>))]
[PXReferentialIntegrityCheck]
public virtual bool? AllowMultiClockEntry { get; set; }

#endregion

#region LaborTimeSeconds

public abstract class laborTimeSeconds : PX.Data.BQL.BqlInt.Field<laborTimeSeconds> { }

[PXDBInt]
[PXUIField(DisplayName = "Labor Time Seconds", Enabled = false, Visible = false)]
[PXDefault(0)]
public virtual int? LaborTimeSeconds { get; set; }

#endregion

 

Userlevel 3
Badge +2

Hi @NageswaraRaoAddanki60 Did it work?

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved