Custom Column is not in the database - acumatica

I have added custom column in InventoryItem using the following:
public abstract class usrAlternateIDs : IBqlField { }
[PXDBString(4000, IsUnicode = true)]
[PXUIField(DisplayName = "Alternate IDs", Visibility = PXUIVisibility.SelectorVisible)]
public string UsrAlternateIDs { get; set; }
But when I use the column for selector like this,
I checked the database table (InventoryItem) and column doesn't exist.

Added custom column in the database using Data Class editor https://help.acumatica.com/(W(3))/?ScreenId=ShowWiki&pageid=96390b13-24a9-41cc-a3f3-3a63b2efa552.

Related

Is there a way to get User Defined Fields into selectors?

I have a customer utilizing the User Defined fields. I found that the values are located in KvExt tables in the database, but I have not found a way to access those directly through DACs or DAC extensions. Is there a way I can access that field and add it to a base Acumatica page?
The specific target in my case is the ARTran.RefNbr selector in the ARPayments page.
As you probably know the User Defined Fields are actually using the Attributes defined in the system. The User Defined Field and actual record (for example ARInvoice) are bound by NoteID of the record (ARInvoice) and RecordID of the User Defined Field. And the FieldName of the User Defined Field is storing word 'Attribute' + AttributeID.
Below SQL Queries show that references:
SELECT CompanyID, RefNbr, DocType, DocDesc FROM ARRegister WHERE RefNbr='AR007092';
SELECT CompanyID, RecordID, FieldName, ValueNumeric, ValueDate, ValueString, ValueText FROM ARRegisterKvExt where RecordID='78A9D6DE-52C4-E911-B2FD-FC017C8C8936';
SELECT CompanyID, AttributeID, Description, ControlType, EntryMask, RegExp, List, IsInternal, ContainsPersonalData FROM CSAttribute WHERE'AttributeBURDEN' LIKE '%'+AttributeID;
And the result sets:
After knowing the references shown above, we can create a DAC to the ARRegisterKvExt table like below:
[PXCacheName("AR Register Attributes")]
[Serializable]
public class ARRegisterKvExt : IBqlTable
{
public abstract class recordID : BqlGuid.Field<recordID> { }
[PXDBGuid(IsKey = true)]
public Guid? RecordID { get; set; }
public abstract class fieldName : BqlString.Field<fieldName> { }
[PXDBString(50,IsKey = true)]
[PXUIField(DisplayName ="Name")]
public string FieldName { get; set; }
public abstract class valueNumeric : BqlDecimal.Field<valueNumeric> { }
[PXDBDecimal(8)]
[PXUIField(DisplayName = "Value Numeric")]
public decimal? ValueNumeric { get; set; }
public abstract class valueDate : BqlDateTime.Field<valueDate> { }
[PXDBDate]
[PXUIField(DisplayName = "Value Date")]
public DateTime? ValueDate { get; set; }
public abstract class valueString : BqlString.Field<valueString> { }
[PXDBString(256)]
[PXUIField(DisplayName = "Value String")]
public string ValueString { get; set; }
public abstract class valueText : BqlString.Field<valueText> { }
[PXDBString]
[PXUIField(DisplayName = "Value Text")]
public string ValueText { get; set; }
}
And write a PXSelector with Left Joins to our DAC and CSAttribute like below:
[PXSelector(typeof(Search2<ARInvoice.refNbr, LeftJoin<ARRegisterKvExt, On<ARInvoice.noteID,Equal<ARRegisterKvExt.recordID>>, LeftJoin<CSAttribute, On<ARRegisterKvExt.fieldName,Contains<CSAttribute.attributeID>>>>>), new[] { typeof(ARInvoice.refNbr), typeof(ARInvoice.docType), typeof(CSAttribute.description), typeof(ARRegisterKvExt.valueString)}, DescriptionField = typeof(ARInvoice.docDesc))]
As a result, you will see lookup like below:
As you can see the AR Invoices which don't have value for the User Defined Fields don't have the Name of the field too. This is caused by the way Acumatica is handling the User Defined Fields. The record for the User Defined Fields is being written to the database only when you set a value. And deletes that record if you clear the value.
The bad side of using the User Defined Fields in the lookups is that if you have 2 User Defined Fields for AR Invoice then the same Invoice will be shown twice, but only if the values for both User Defined Fields are set.

How can I get a prepopulated inventory field to show only the InventoryID and not the description (Acumatica)

We have a custom graph that was built for us by Acumatica; it uses a PXProjection called by the primary graph's PXSelectJoin to select data and populate the fields.
A couple of fields are inventory ID fields:
#region KitComponentID
public abstract class kitComponentID : IBqlField { }
[StockItem(DisplayName = "Kit Component ID", IsKey = true, BqlField = typeof(INKitSpecStkDet.compInventoryID))]
public virtual int? KitComponentID { get; set; }
#endregion
#region KitInventoryID
public abstract class kitInventoryID : IBqlField { }
[SOLineInventoryItem(DisplayName = "Kit ID", BqlField = typeof(SOLine.inventoryID))]
public virtual int? KitInventoryID { get; set; }
#endregion
These fields are not user editable, only for display. We would like to have them display only the InventoryCD, not the CD and description.
Is there a different way I can define my fields so that they are still automatically populated but display only the InventoryCD?
Under the screen editor, the field should have a drop-down of DisplayMode. By default, I believe it's Hint (which is Key + Description), Value (which is just key), and Text (which is Description.)
If you change the DisplayMode to Value, it should give you what you want.

Custom grid with custom DAC, Multiple keys adding unwanted rows

I've created a very simple data entry grid, I'm having an issue when I attempt to assign more than 1 isKey value in the attributes on my custom DAC. I have two fields that I need to be unique as a pair, Direct customer and Indirect customer. When I add the IsKey = true to both Direct/Indirect the grid functions abnormally and adds two rows, one with a missing indirect.
When I remove one Iskey the grid functions fine, only when the second key is added the bug occurs. I'm trying to use Direct
Below bug added empty row when using two IsKey=true on Direct Customer and Indirect Customer.
Below when only one key is used on Direct Customer, correct functionality with no duplicate row.
Data View Declaration
Modified SQL Table for make Direct and Indirect customers to be a Primary Key
DAC declaration of the keys:
#region RecordID
[PXDBIdentity()]
[PXUIField(DisplayName = "Record ID")]
public int? RecordID { get; set; }
public class recordID : IBqlField{}
#endregion
#region DirectCustomer
[PXDBInt(IsKey = true)]
[PXUIField(DisplayName = "Direct Customer")]
[PXSelector(typeof(PX.Objects.AR.Customer.bAccountID),
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
SubstituteKey = typeof(PX.Objects.AR.Customer.acctName))]
public int? DirectCustomer { get; set; }
public class directCustomer : IBqlField{}
#endregion
#region IndirectCustomer
[PXDBString(100,IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Indirect Customer")]
[PXSelector(typeof(Search<PX.Objects.AR.Customer.acctCD,
Where<PX.Objects.CR.BAccountExt.usrIndirectCust, Equal<True>>>),
typeof(PX.Objects.AR.Customer.acctCD),
typeof(PX.Objects.AR.Customer.acctName),
SubstituteKey = typeof(PX.Objects.AR.Customer.acctName))]
public string IndirectCustomer { get; set; }
public class indirectCustomer : IBqlField{}
#endregion

PxProjection - how to use filter parameters in the Select class?

I use PxProjection attribute in a way that select the specific fields of DACs. How should I pass filter parameter in the select command(the same way as it is in the graph by using Or<CRInsurancePolicy.currentreportsTo, Equal<Current<BAccountParam.bAccountID>>> ) in order to have filtered data in the graph?
I propose to look at Select2 attribute in PXProjection.
Select2 attribute allows to use filter - all possible commands of BQL (Join, Where, GroupBy, OrderBy).
For examle here, the attribute joins data from two table and projects it to the single DAC:
[Serializable]
[PXProjection(typeof(Select2<Supplier,
InnerJoin<SupplierProduct,
On<SupplierProduct.accountID, Equal<Supplier.accountID>>>>))]
public partial class SupplierPrice : IBqlTable
{
public abstract class accountID : PX.Data.IBqlField
{
}
// The field mapped to the Supplier field (through setting of BqlField)
[PXDBInt(IsKey = true, BqlField = typeof(Supplier.accountID))]
public virtual int? AccountID { get; set; }
public abstract class productID : PX.Data.IBqlField
{
}
// The field mapped to the SupplierProduct field
// (through setting of BqlField)
[PXDBInt(IsKey = true, BqlField = typeof(SupplierProduct.productID))]
[PXUIField(DisplayName = "Product ID")]
public virtual int? ProductID { get; set; }
...
}

Search in GI Gives error while using Sector field

I have created a Name value pair field for Sales Order table and Search is giving error while using the field from Description field in selector
#region UsrLoader
public abstract class usrLoader : IBqlField { }
[PXDBString(128, IsUnicode = true)]
[PXUIField(DisplayName = "Operator 1")]
[PXSelector(typeof(EPEmployee.acctCD),
new Type[]
{
typeof(EPEmployee.acctCD),
typeof(EPEmployee.acctName)
},
DescriptionField = typeof(EPEmployee.acctName))]
public virtual string UsrLoader { get; set; }
#endregion
#region UsrUnLoader
[PXDBString(128)]
[PXUIField(DisplayName = "Operator 2")]
[PXSelector(typeof(EPEmployee.acctCD),
new Type[]
{
typeof(EPEmployee.acctCD),
typeof(EPEmployee.acctName)
},
DescriptionField = typeof(EPEmployee.acctName))]
public virtual string UsrUnLoader { get; set; }
public abstract class usrUnLoader : IBqlField { }
#endregion
I am getting the following error
Typically I see the Invalid column error when the customization hasn't been published to insert the field in the database table. Did you publish after adding the fields?
Also, the warnings might tell you to join in the parent table. Did you try doing a join to the EPEmployee table to use the description/name field in your GI?

Resources