Solved

Error: The entry form (ID: PM301000, title: Projects) cannot be automated. An error occurred during processing of the field Through Date: Index was outside the bounds of the array..

  • 23 December 2021
  • 7 replies
  • 535 views

Userlevel 7
Badge +8

I have added a Cutom Int Field to store start and end date duration in month(s) but when I open Projects form I get this “Error: The entry form (ID: PM301000, title: Projects) cannot be automated. An error occurred during processing of the field Through Date: Index was outside the bounds of the array.”

I know the problem is caused by PXDBCalced and when I take it away it works. Can you please advise what I’m doing wrong?

Here is the field that I have added

        #region UsrLGProjectDuration
public abstract class usrLGProjectDuration : PX.Data.BQL.BqlInt.Field<usrLGProjectDuration> { }
protected Int32? _UsrLGProjectDuration;
[PXDBInt()]
[PXDefault(0, PersistingCheck = PXPersistingCheck.Nothing)]
[PXDBCalced(typeof(
IIf<Where<PMProject.startDate, IsNotNull>,
IIf<Where<PMProject.expireDate, IsNotNull>,
IIf<Where<PMProject.startDate, Less<PMProject.expireDate>>,
DateDiff<PMProject.startDate, PMProject.expireDate, DateDiff.month>, Zero>, Zero>, Zero>),
typeof(int))]
[PXUIField(DisplayName = "Project Duration", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]
public virtual Int32? UsrLGProjectDuration
{
get
{
return this._UsrLGProjectDuration;
}
set
{
this._UsrLGProjectDuration = value;
}
}
#endregion

 

icon

Best answer by Naveen Boga 24 December 2021, 05:34

View original

7 replies

Userlevel 7
Badge +17

@aaghaei   Awesome, Thanks for sharing the update 🙂

Userlevel 7
Badge +8

Thanks @Naveen B , sorry my bad that I missed that part. The issue is resolved.

Userlevel 7
Badge +17

Hi @aaghaei  I think you have NOT taken the code from here and verified.

The above given code is working for me, and I have removed typeof(int) from your original code and re-shared the code above.

 

 

Userlevel 7
Badge +8

Hi @Naveen B , this is what I tried that I got that long error copied above for you. you basically suggested to take out “PXDBCalced” and replace it with “PXFormula” that I did and received that lenghty error copied above

 

Userlevel 7
Badge +17

Hi  @aaghaei  Can you try below code and verify.

 #region UsrLGProjectDuration
public abstract class usrLGProjectDuration : PX.Data.BQL.BqlInt.Field<usrLGProjectDuration> { }
protected Int32? _UsrLGProjectDuration;
[PXDBInt()]
[PXDefault(0, PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(
IIf<Where<PMProject.startDate, IsNotNull>,
IIf<Where<PMProject.expireDate, IsNotNull>,
IIf<Where<PMProject.startDate, Less<PMProject.expireDate>>,
DateDiff<PMProject.startDate, PMProject.expireDate, DateDiff.month>, Zero>, Zero>, Zero>))]
[PXUIField(DisplayName = "Project Duration", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]
public virtual Int32? UsrLGProjectDuration
{
get
{
return this._UsrLGProjectDuration;
}
set
{
this._UsrLGProjectDuration = value;
}
}
#endregion

 

Userlevel 7
Badge +8

Thanks @Naveen B,

 

Now I get this 

Index was outside the bounds of the array.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:
 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:
 

[IndexOutOfRangeException: Index was outside the bounds of the array.]
PX.Data.PXGraph.CreateInstance(Type graphType, String prefix) +1132
PX.Web.UI.PXBaseDataSource.CreateDataGraphAsSingleton(Type type) +560
PX.Web.UI.PXBaseDataSource.CreateDataGraph(Type type) +175
PX.Web.UI.PXBaseDataSource.get_DataGraph() +412
PX.Web.UI.PXBaseDataSource.GetActions(Boolean primary) +308
PX.Web.UI.PXBaseDataSource.GetCommands(Boolean all) +118
PX.Web.UI.PXBaseDataSource.GetCommandStates() +141
PX.Web.UI.PXGrid.CorrectTollbarButtons() +185
PX.Web.UI.PXGrid.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +548
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +230
System.Web.UI.Control.EnsureChildControls() +130
System.Web.UI.WebControls.CompositeDataBoundControl.get_Controls() +24
PX.Web.UI.PXSmartPanel.CollectInnerControls(ControlCollection controls, Boolean load, Boolean collectUpdatable) +347
PX.Web.UI.PXSmartPanel.CollectInnerControls(Boolean load) +110
PX.Web.UI.PXSmartPanel.SetBindingState(Boolean load) +109
PX.Web.UI.PXSmartPanel.OnInit(EventArgs e) +99
System.Web.UI.Control.InitRecursive(Control namingContainer) +454
System.Web.UI.Control.InitRecursive(Control namingContainer) +219
System.Web.UI.Control.InitRecursive(Control namingContainer) +219
System.Web.UI.Control.InitRecursive(Control namingContainer) +219
System.Web.UI.Control.InitRecursive(Control namingContainer) +219
System.Web.UI.Control.InitRecursive(Control namingContainer) +219
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1719
Userlevel 7
Badge +17

Hi @aaghaei  As per my knowledge, PXDBCalced will work with Unbound fields but NOT database fields.

Since above DAC field is database field, please use PXFormula and verify.

I have not tested this, but hope this works!

  #region UsrLGProjectDuration
public abstract class usrLGProjectDuration : PX.Data.BQL.BqlInt.Field<usrLGProjectDuration> { }
protected Int32? _UsrLGProjectDuration;
[PXDBInt()]
[PXDefault(0, PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(
IIf<Where<PMProject.startDate, IsNotNull>,
IIf<Where<PMProject.expireDate, IsNotNull>,
IIf<Where<PMProject.startDate, Less<PMProject.expireDate>>,
DateDiff<PMProject.startDate, PMProject.expireDate, DateDiff.month>, Zero>, Zero>, Zero>),
typeof(int))]
[PXUIField(DisplayName = "Project Duration", Visibility = PXUIVisibility.SelectorVisible, Required = true, Enabled = true, Visible = true)]
public virtual Int32? UsrLGProjectDuration
{
get
{
return this._UsrLGProjectDuration;
}
set
{
this._UsrLGProjectDuration = value;
}
}
#endregion

 

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