Solved

Populating custom data field's values

  • 3 September 2021
  • 19 replies
  • 774 views

I have a custom table being added to the database and maintained with a new screen. I want to add a combo box to an existing screen that gets populated with the values form my new custom table. I cant seem to find documentation on this type of scenario and how I can go about this. 

icon

Best answer by Naveen Boga 3 September 2021, 17:13

View original

19 replies

Userlevel 7
Badge +5

Just to confirm - you want a combo box and not a selector?

@ddunn 
Any type of multi-value control will do as long as I can fill the values from my custom SQL table

Userlevel 7
Badge +5

Is your custom table set up as a DAC?  If so then you’ll want to look at the PXSelector attribute on the field that you want to enable with the lookup functionality.

Once you change the field to add the PXSelector attribute then you’ll need to modify the related field control on the screen so that it is no longer a text field.  Probably easiest to remove the field from the screen, save, publish and then re-add the field and it will use a selector control.

@ddunn Yes I have configured the PXSelector attribute inside of my custom field but I am receiving an error when I try to publish

 

This is my PXSelector line:

[PXSelector(typeof(Search<ProjectCode.projectCodeID>))]

 

Error message:

CS0246: The type or namespace name 'ProjectCode' could not be found (are you missing a using directive or an assembly reference?)
Userlevel 7
Badge +5

ProjectCode should be a DAC visible to your project.

Yes the ProjectCode class is a public class under the Code section of my customization project that I created like this:

 

 

Userlevel 7
Badge +5

Are the namespaces the same for your project code files?

Yes they are named the same. The error seems to be coming from the Data Access Class’ extension. 

Userlevel 7
Badge +5

Hmmm - I’m not sure.  Maybe post your code?

Userlevel 7
Badge +17

@ryanmoon32  As suggested by ddunn, Can you please share you DAC and Graph code here.

OK @ddunn @Naveen B here is all the info on my project..

M504000 is a new screen that is used to maintain the project codes (new SQL table) that I want to fill this selector/combobox control which will be added to the AP303000 screen.

 

The graph for M504000 is ProjectCodesMaint while the DAC class is ProjectCode

Here is the graph and DAC class for the two code classes:

using System;
using PX.Data;

namespace M5_Blaze_ProjectCodes
{

[PXCacheName("Project Codes")]
public class ProjectCode : IBqlTable
{
#region ProjectCodeID
[PXDBString(20, IsKey = true, IsFixed = true, IsUnicode = true, InputMask = ">aaaaaa")]
[PXDefault]
[PXUIField(DisplayName = "Code")]
public virtual string ProjectCodeID { get; set; }
public abstract class projectCodeID : PX.Data.BQL.BqlString.Field<projectCodeID> { }
#endregion

#region Description
[PXDBString(60, IsFixed = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[PXUIField(DisplayName = "Description")]
public virtual string Description { get; set; }
public abstract class description : PX.Data.BQL.BqlString.Field<description> { }
#endregion

#region CreatedDateTime
[PXDBCreatedDateTime()]
public virtual DateTime? CreatedDateTime { get; set; }
public abstract class createdDateTime : PX.Data.BQL.BqlDateTime.Field<createdDateTime> { }
#endregion

#region CreatedByID
[PXDBCreatedByID()]
public virtual Guid? CreatedByID { get; set; }
public abstract class createdByID : PX.Data.BQL.BqlGuid.Field<createdByID> { }
#endregion

#region CreatedByScreenID
[PXDBCreatedByScreenID()]
public virtual string CreatedByScreenID { get; set; }
public abstract class createdByScreenID : PX.Data.BQL.BqlString.Field<createdByScreenID> { }
#endregion

#region LastModifiedDateTime
[PXDBLastModifiedDateTime()]
public virtual DateTime? LastModifiedDateTime { get; set; }
public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field<lastModifiedDateTime> { }
#endregion

#region LastModifiedByID
[PXDBLastModifiedByID()]
public virtual Guid? LastModifiedByID { get; set; }
public abstract class lastModifiedByID : PX.Data.BQL.BqlGuid.Field<lastModifiedByID> { }
#endregion

#region LastModifiedByScreenID
[PXDBLastModifiedByScreenID()]
public virtual string LastModifiedByScreenID { get; set; }
public abstract class lastModifiedByScreenID : PX.Data.BQL.BqlString.Field<lastModifiedByScreenID> { }
#endregion

#region Tstamp
[PXDBTimestamp()]
public virtual byte[] Tstamp { get; set; }
public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field<tstamp> { }
#endregion

#region Noteid
[PXNote()]
public virtual Guid? Noteid { get; set; }
public abstract class noteid : PX.Data.BQL.BqlGuid.Field<noteid> { }
#endregion

}
}
using System;
using PX.Data;
using PX.Data.BQL.Fluent;

namespace M5_Blaze_ProjectCodes
{
public class ProjectCodesMaint : PXGraph<ProjectCodesMaint>
{

public PXSave<ProjectCode> Save;
public PXCancel<ProjectCode> Cancel;
public SelectFrom<ProjectCode>.View ProjectCodeView;

}
}

The PrimaryView and DataMember of M504000 are both set to ProjectCodeView and work correctly.

 

The issues start when I attempt to add this ProjectCode field/class to a field on the AP screen, which then automatically creates the Data Access class/extension(?) which ultimately is what throws the error as seen in quote below.

 

 

Error:

\App_RuntimeCode\PX_Objects_CR_BAccount_extensions.cs(26): error CS0246: The type or namespace name 'ProjectCode' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\PX_Objects_CR_BAccount_extensions.cs(26): error CS0246: The type or namespace name 'ProjectCode' could not be found (are you missing a using directive or an assembly reference?)

 

 

I know this is a ton of info, so I am very thankful for your help and patience!

 

Userlevel 7
Badge +5

That helps, thanks!

I suspect that what is happening is that the code that the screen changes are being managed within has the wrong namespace.  Naveen might know of a way to do that within the project without moving it to Visual Studio but I would be tempted to have you consider moving the project to Visual Studio.

Userlevel 7
Badge +17

Hi @ryanmoon32  This is an issue with namespace.

In the BAccount Extended DAC, you have used the “ProjectCode” DAC, but the namespace you have NOT added, due to this BAccount extended DAC unable to find the ProjectCode DAC and resulting error.

 

If above message is confusing you just share the share the BAccount extended DAC from App_Runtime folder from Visual Studio, I will tell you what exactly you need to do to fix this issue. 

@Naveen B By mentioning the BAccount DAC extension, you reminded me of something.. I can now get the selector control to populate by overriding the DAC class like this:

using PX.Data.BQL.Fluent;
using PX.Data.EP;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CR.MassProcess;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.TX;
using PX.Objects;
using PX.SM;
using PX.TM;
using System.Collections.Generic;
using System.Diagnostics;
using System;

namespace M5_Blaze_ProjectCodes
{
public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
{
#region UsrProjectCodeID
[PXString(20)]
[PXSelector(typeof(Search<ProjectCode.projectCodeID>), typeof(ProjectCode.projectCodeID), typeof(ProjectCode.description))]
[PXDefault]
[PXUIField(DisplayName="Project Code")]
public virtual string UsrProjectCodeID{ get; set; }
public abstract class usrProjectCodeID : PX.Data.BQL.BqlString.Field<usrProjectCodeID > { }
#endregion
}
}

 

The values are showing up in the selector control but they still are not actually committed to the SQL table even though that UsrProjectCodeID field exist in the BAccount table now. It seems there is still a disconnect.

UPDATE: It is now working.. The first attribute of that UsrProjectCodeID should have been PXDBString instead of PXString.

 

Thanks again for all the help, saved me a ton of time. @ddunn @Naveen B 

Userlevel 7
Badge +17

Hi @ryanmoon32  Everything seems to be good here. Can you please share that package, I will publish my local machine and check from my end.

Userlevel 7
Badge +17

@ryanmoon32  Oh Great :) Thanks for the update.

hi. what should i do? the error that ive encountered was “the type or namespace “Fluent” does not exist in the namespace PX.Data.BQL (are you missing an assembly reference?)”  im using VS 2019 with Acuminator Extension. thanks in advance

 

Userlevel 7
Badge +17

@bcsmis408  Add below DLL to project reference like below.

 

 

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