PXCustomizeSelectorColumns messes up column names - acumatica

I'm using the following code to add postal code to the BA selector on the Case screen.
It works and adds the new column, but it messes up the column names. See the screenshot below the code.
How can I get around this? Is there a way to pass the column headers in the PXCustomizeSelectorColumns attribute?
[PXNonInstantiatedExtension]
public class CR_CRCase_ExistingColumn : PXCacheExtension<PX.Objects.CR.CRCase>
{
#region CustomerID
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXCustomizeSelectorColumns(
typeof(PX.Objects.CR.BAccountR.acctCD),
typeof(PX.Objects.CR.BAccountR.acctName),
typeof(PX.Objects.CR.BAccountR.type),
typeof(PX.Objects.CR.BAccount.classID),
typeof(PX.Objects.CR.BAccountR.status),
typeof(PX.Objects.CR.Contact.phone1),
typeof(PX.Objects.CR.Address.city),
typeof(PX.Objects.CR.Address.countryID),
typeof(PX.Objects.CR.Contact.eMail),
typeof(PX.Objects.CR.Address.postalCode))]
public int? CustomerID { get; set; }
#endregion
}
[CustomerAndProspect(DisplayName = "Business Account")]
[PXRestrictor(typeof(Where<Current<CRCaseClass.requireCustomer>, Equal<False>,
Or<BAccount.type, Equal<BAccountType.customerType>,
Or<BAccount.type, Equal<BAccountType.combinedType>>>>), Messages.CustomerRequired, typeof(BAccount.acctCD))]
[PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(typeof(Switch<Case<Where<CRCase.caseClassID, IsNotNull, And<Selector<CRCase.caseClassID, CRCaseClass.requireCustomer>, Equal<True>,
And<Current<CRCase.customerID>, IsNotNull, And<Selector<Current<CRCase.customerID>, BAccount.type>, Equal<BAccountType.prospectType>>>>>,
Null>,
CRCase.customerID>))]
[PXFormula(typeof(Switch<Case<Where<Current<CRCase.customerID>, IsNull, And<Current<CRCase.contractID>, IsNotNull>>,
IsNull<Selector<CRCase.contractID, Selector<ContractBillingSchedule.accountID, BAccount.acctCD>>,
Selector<CRCase.contractID, Selector<Contract.customerID, BAccount.acctCD>>>>,
CRCase.customerID>))]
[PXFormula(typeof(Switch<Case<Where<Current<CRCase.customerID>, IsNull,
And<Current<CRCase.contactID>, IsNotNull,
And<Selector<CRCase.contactID, Contact.bAccountID>, IsNotNull>>>,
Selector<CRCase.contactID, Selector<Contact.bAccountID, BAccount.acctCD>>>,
CRCase.customerID>))]
Here's my current code. It pulls the zip code in, but it now shows all BAccounts not just customers and prospects. The code does not give any errors when checking it in Acuminator.
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(PXDimensionSelectorAttribute))]
[PXDimensionSelector(BAccountAttribute.DimensionName,
typeof(Search2<
BAccountR.bAccountID,
LeftJoin<Contact,
On<Contact.bAccountID, Equal<BAccountR.bAccountID>,
And<Contact.contactID, Equal<BAccountR.defContactID>>>,
LeftJoin<Address,
On<Address.bAccountID, Equal<BAccountR.bAccountID>,
And<Address.addressID, Equal<BAccountR.defAddressID>>>>>,
Where<
Match<Current<AccessInfo.userName>>,
And<Where<BAccountR.type, Equal<BAccountType.prospectType>,
Or<BAccountR.type, Equal<BAccountType.customerType>,
Or<BAccountR.type, Equal<BAccountType.combinedType>>>>>
>>),
substituteKey: typeof(BAccountR.acctCD),
fieldList: new[]
{
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(BAccountR.type),
typeof(BAccountR.classID),
typeof(BAccountR.status),
typeof(Contact.phone1),
typeof(Address.city),
typeof(Address.postalCode),
typeof(Address.countryID),
typeof(Contact.eMail)
}
)]
protected virtual void CRCase_CustomerID_CacheAttached(PXCache cache)
{
}
I'm getting these errors on compile:
\App_RuntimeCode\CRCaseMaint.cs(84): error CS0311: The type 'PX.Data.Match<PX.Data.Current<PX.Data.AccessInfo.userName>>' cannot be used as type parameter 'Operand' in the generic type or method 'Where<Operand, Comparison>'. There is no implicit reference conversion from 'PX.Data.Match<PX.Data.Current<PX.Data.AccessInfo.userName>>' to 'PX.Data.IBqlOperand'.
\App_RuntimeCode\CRCaseMaint.cs(85): error CS0311: The type 'PX.Data.And<PX.Data.Where<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.prospectType>, PX.Data.Or<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.customerType>, PX.Data.Or<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.combinedType>>>>>' cannot be used as type parameter 'Comparison' in the generic type or method 'Where<Operand, Comparison>'. There is no implicit reference conversion from 'PX.Data.And<PX.Data.Where<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.prospectType>, PX.Data.Or<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.customerType>, PX.Data.Or<PX.Objects.CR.BAccountR.type, PX.Data.Equal<PX.Objects.CR.BAccountType.combinedType>>>>>' to 'PX.Data.IBqlComparison'.
\App_RuntimeCode\CRCaseMaint.cs(84): error CS0311: The type 'PX.Data.Match<PX.Data.Current<PX.Data.AccessInfo.userName>>' cannot be used as type parameter 'Operand' in the generic type or method 'Where<Operand, Comparison>'. There is no implicit reference conversion from 'PX.Data.Match<PX.Data.Current<PX.Data.AccessInfo.userName>>' to 'PX.Data.IBqlOperand'.
I also tried copying the PXRestrictor attribute from the CustomerAndProspectAttribute, but it seemed to ignore it.
#region CustomerAndProspectAttribute
[PXRestrictor(typeof(Where<BAccountR.type, Equal<BAccountType.prospectType>,
Or<BAccountR.type, Equal<BAccountType.customerType>,
Or<BAccountR.type, Equal<BAccountType.combinedType>>>>), Messages.BAccountIsType, typeof(BAccountR.type))]

I just overridden the dimension selector this way:
public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(PXDimensionSelectorAttribute))]
[PXDimensionSelector(BAccountAttribute.DimensionName,
typeof(Search2<
BAccountR.bAccountID,
LeftJoin<Contact,
On<Contact.bAccountID, Equal<BAccountR.bAccountID>,
And<Contact.contactID, Equal<BAccountR.defContactID>>>,
LeftJoin<Address,
On<Address.bAccountID, Equal<BAccountR.bAccountID>,
And<Address.addressID, Equal<BAccountR.defAddressID>>>>>,
Where<
Match<Current<AccessInfo.userName>>>>),
substituteKey: typeof(BAccountR.acctCD),
fieldList: new[]
{
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(BAccountR.type),
typeof(BAccountR.classID),
typeof(BAccountR.status),
typeof(Contact.phone1),
typeof(Address.city),
typeof(Address.postalCode),
typeof(Address.countryID),
typeof(Contact.eMail)
}
)]
protected virtual void CROpportunity_BAccountID_CacheAttached(PXCache cache)
{
}
}
Managed to expose the postal code :
Not sure if this is the most efficient way of doing it. But it ticks the box.

Related

How can I enter a value in a Selector that doesn't exist in the selection values

I have to ask this question, because the solution in this case (using ValidateValue = false) didn't work for me:
Acumatica PXselector, how to type new value into selector control
Here's my selector
public abstract class sourceAccount : PX.Data.BQL.BqlString.Field<sourceAccount> { }
[PXDBInt]
[PXUIField(DisplayName = "Source Account")]
[PXSelector(typeof(Search<Account.accountID,
Where<Account.active, Equal<True>>>),
typeof(Account.accountCD),
typeof(Account.description),
SubstituteKey = typeof(Account.accountCD),
DescriptionField = typeof(Account.description),
ValidateValue = false)]
public virtual Int32? SourceAccount { get; set; }
When this is compiled and deployed, I still get this:
Any idea why this wouldn't work for me?
The trace of the error:
First simplify selector logic:
[PXSelector(typeof(Search<Account.accountID>), ValidateValue = false)]
Then lookup all references to sourceAccount / SourceAccount to check for additional validations.
And make sure the value entered matches at DAC and DB side.
You are entering a string value when the DAC field is an integer, that will not work.

Add Attribute in “Add Item” dialog box in Purchase Order screen of Acumatica

How can I add an Attribute column from "Stock Items" screen to "Add Item" dialog box of Purchase Order screen. I want to add the following attribute from Stock Items screen to the "Add Item" Dialog box of Purchase Order Screen.
Please review the images below for Stock Item and Purchase Order Screens.
I am able to get the field in the inventory lookup of PO, the values did not populated.
here goes my code....
namespace PX.Objects.PO
{
[PXProjection(typeof(Select<CSAnswers, Where<CSAnswers.refNoteID, Equal<POSiteStatusSelected.noteID>,
And<CSAnswers.attributeID, Equal<AttribMyAttribute>>>>), Persistent = false)]
public class POSiteStatusSelectedExt : PXCacheExtension<PX.Objects.PO.POSiteStatusSelected>
{
#region UsrItemType
[PXDBString(10, IsFixed = true, BqlField = typeof(CSAnswers.value))]
[PXUIField(DisplayName = "Item Type")]
//[PXDBScalar(typeof(Search<CSAnswers.value, Where<CSAnswers.refNoteID, Equal<POSiteStatusSelected.noteID>,
// And<CSAnswers.attributeID, Equal<AttribMyAttribute>>>>))]
public virtual string UsrItemType { get; set; }
public abstract class usrItemType : IBqlField { }
#endregion
}
public class AttribMyAttribute : Constant<string>
{
public AttribMyAttribute() : base("ITEMTYPE") { }
}
}
I have created a DAC extension of POSiteStatusSeleted view and added my custom field which is a non-persisted field. There is noteId field in the POSiteStatusSeleted which is of type InventoryItem.noteID, i tried to use the same in the PXDBScalar attribute(the code line is commented), this also didn't work out, it was showing an error for "Unable to convert System.Int32 to System.String".
Updated Answer: Because of the projection, we have to create a new class that inherits the DAC and uses the [PXSubstitute] attribute. The nature of PXSubstitute means that this will not be a DAC extension or even part of a Graph Extension. In my testing, I tried encapsulating this in a graph extension on POOrderEntry, and it did not work. By following the instructions of the stack overflow post below, I was able to create an Attribute called ITEMTYPE, assign it to one of my Item Classes, replace the PXProjection with an enhanced version that includes a left join back to the attribute table (CSAnswers) and then add it to the screen's smart panel grid.
Extend Acumatica Projection Based DAC Query
In the code sample below, the magic is in PXSubstitute, which will take the new class that you create and inherit from the base DAC and replace that base DAC with your new one. If you specify a graph, it will perform the substitution in only that graph (or each graph you specify - 1 per PXSubstitute attribute used). If you do not specify a graph, it will override the base DAC in every case it is used within the xRP Framework.
Code to perform the stated modification:
using PX.Data;
using PX.Objects.AP;
using PX.Objects.Common.Bql;
using PX.Objects.CS;
using PX.Objects.IN;
using System;
namespace PX.Objects.PO
{
[System.SerializableAttribute()]
[PXProjection(typeof(Select2<InventoryItem,
LeftJoin<CSAnswers,
On<CSAnswers.refNoteID, Equal<InventoryItem.noteID>,
And<CSAnswers.attributeID, Equal<AttribItemType>>>,
LeftJoin<INSiteStatus,
On<INSiteStatus.inventoryID, Equal<InventoryItem.inventoryID>, And<INSiteStatus.siteID, NotEqual<SiteAttribute.transitSiteID>>>,
LeftJoin<INSubItem,
On<INSiteStatus.FK.SubItem>,
LeftJoin<INSite,
On<INSiteStatus.FK.Site>,
LeftJoin<INItemXRef,
On<INItemXRef.inventoryID, Equal<InventoryItem.inventoryID>,
And2<Where<INItemXRef.subItemID, Equal<INSiteStatus.subItemID>,
Or<INSiteStatus.subItemID, IsNull>>,
And<Where<CurrentValue<POSiteStatusFilter.barCode>, IsNotNull,
And<INItemXRef.alternateType, Equal<INAlternateType.barcode>>>>>>,
LeftJoin<INItemPartNumber,
On<INItemPartNumber.inventoryID, Equal<InventoryItem.inventoryID>,
And<INItemPartNumber.alternateID, Like<CurrentValue<POSiteStatusFilter.inventory_Wildcard>>,
And2<Where<INItemPartNumber.bAccountID, Equal<Zero>,
Or<INItemPartNumber.bAccountID, Equal<CurrentValue<POOrder.vendorID>>,
Or<INItemPartNumber.alternateType, Equal<INAlternateType.cPN>>>>,
And<Where<INItemPartNumber.subItemID, Equal<INSiteStatus.subItemID>,
Or<INSiteStatus.subItemID, IsNull>>>>>>,
LeftJoin<INItemClass,
On<InventoryItem.FK.ItemClass>,
LeftJoin<INPriceClass,
On<INPriceClass.priceClassID, Equal<InventoryItem.priceClassID>>,
LeftJoin<Vendor,
On<Vendor.bAccountID, Equal<InventoryItem.preferredVendorID>>,
LeftJoin<INUnit,
On<INUnit.inventoryID, Equal<InventoryItem.inventoryID>,
And<INUnit.unitType, Equal<INUnitType.inventoryItem>,
And<INUnit.fromUnit, Equal<InventoryItem.purchaseUnit>,
And<INUnit.toUnit, Equal<InventoryItem.baseUnit>>>>>>>>>>>>>>>,
Where2<CurrentMatch<InventoryItem, AccessInfo.userName>,
And2<Where<INSiteStatus.siteID, IsNull, Or<INSite.branchID, IsNotNull, And2<CurrentMatch<INSite, AccessInfo.userName>,
And<Where2<FeatureInstalled<FeaturesSet.interBranch>,
Or2<SameOrganizationBranch<INSite.branchID, Current<POOrder.branchID>>,
Or<CurrentValue<POOrder.orderType>, Equal<POOrderType.standardBlanket>>>>>>>>,
And2<Where<INSiteStatus.subItemID, IsNull,
Or<CurrentMatch<INSubItem, AccessInfo.userName>>>,
And<InventoryItem.stkItem, Equal<boolTrue>,
And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.inactive>,
And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.unknown>,
And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.markedForDeletion>,
And<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.noPurchases>>>>>>>>>>), Persistent = false)]
//[PXSubstitute(GraphType = typeof(POOrderEntry))]
[PXSubstitute]
public partial class POSiteStatusSelectedCst : POSiteStatusSelected
{
#region UsrItemType
[PXDBString(10, BqlField = typeof(CSAnswers.value))]
[PXUIField(DisplayName = "Item Type")]
public string UsrItemType { get; set; }
public abstract class usrItemType : PX.Data.BQL.BqlString.Field<usrItemType> { }
#endregion
}
public class AttribItemType : PX.Data.BQL.BqlString.Constant<AttribItemType>
{
public AttribItemType() : base("ITEMTYPE") { }
}
}

error CS0592: Attribute 'PXForeignReference' is not valid on this declaration type. It is only valid on 'class, property, indexer' declarations

Good day
I need to override the InventoryID field on the Purchase Orders screen. I want to make the field a Required field by overriding it on-screen level:
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
#region Event Handlers
[PXDefault]
[POLineInventoryItem(Filterable = true)]
[PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
protected virtual void POLine_InventoryID_CacheAttached(PXCache cache)
{
}
#endregion
}
}
When I run the above I get the following error:
\App_RuntimeCode\POOrderEntry.cs(45): error CS0592: Attribute 'PXForeignReference' is not valid on this declaration type. It is only valid on 'class, property, indexer' declarations.
Line 45 is [PXForeignReference(typeof(Field.IsRelatedTo<InventoryItem.inventoryID>))]
How would I go about fixing this error?
I don't believe foreign reference is "legal" in the context of CacheAttached. You should be able to use PXMergeAttrubutes to add PXDefault without dropping the other attributes.
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXDefault]
protected virtual void POLine_InventoryID_CacheAttached(PXCache cache){}
I did something similar to prevent use of a specific Item Class on SOLine.
#region SOLine_InventoryID_CacheAttached
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<InventoryItem.itemClassID,
NotEqual<Current<MySetup.PreventClassID>>>),"")]
protected virtual void SOLine_InventoryID_CacheAttached(PXCache sender) { }
#endregion
You also might consider PXUIRequiredAttribute if you want to define when it would be required. I believe this attribute can be used in a DAC Extension or CacheAttached.
#region MyDAC_AccountID_CacheAttached
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXDefault()]
[PXUIRequired(typeof(Where<Current<MyDAC.hold>, Equal<False>,
And<Current<MyBranchSetting.requireAccount>, Equal<True>>>))]
protected virtual void MyDAC_AccountID_CacheAttached(PXCache sender) { }
#endregion

Show unbound field with PXFormula

I'm trying to show a value calculated with PXFormula but the field doesn't show the value.
I have my CustomDAC named EDITran
public class EDITran : IBqlTable
{
#region Doctype
[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Doctype")]
[PXStringList
(new string[]
{"SO", "SHI", "INV" },
new string[]
{"Sales Order", "Shipment", "Invoice"}
)]
public virtual string Doctype { get; set; }
public abstract class doctype : PX.Data.BQL.BqlString.Field<doctype> { }
#endregion
#region Erprefnbr
[PXDBString(30, IsKey = true, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "ERP RefNbr")]
public virtual string Erprefnbr { get; set; }
public abstract class erprefnbr : PX.Data.BQL.BqlString.Field<erprefnbr> { }
#endregion
#region Sync
[PXDBBool()]
[PXUIField(DisplayName = "Sync")]
public virtual bool? Sync { get; set; }
public abstract class sync : PX.Data.BQL.BqlBool.Field<sync> { }
#endregion
}
}
so I what to show the value of sync field on the Sales Order screen. The key is the ERP RefNbr (which would be SOOrder.OrderNbr)
I have added the custom non persisted field on the SOOrderExt DAC with this attributes
using PX.Objects.SO;
[PXBool]
[PXUIField(DisplayName="EDI Sync" , Enabled = false)]
[PXFormula(typeof(Selector<SOOrder.orderNbr,
Selector<EDITran.erprefnbr,
EDITran.sync>>))]
But when I added a record in EDITran and try to visualize it in SOOrder Form and I checked that EDITran.Sync = 1, it doesn't show the saved value.
Sales Order Screen
What I'm I doing wrong? Is the PXFormula correctly used?
PXFormula used incorrectly. PXFormula attribute works only with current DAC (which is SOOrder) or foreign DAC, existing in PXSelector join condition (you can use Selector keyword to get it).
For example, here is the SOOrder.OrderNbr selector declaration
[SO.RefNbr(typeof(Search2<SOOrder.orderNbr,
LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>,
And<Where<Match<Customer, Current<AccessInfo.userName>>>>>>,
Where<SOOrder.orderType, Equal<Optional<SOOrder.orderType>>,
And<Where<Customer.bAccountID, IsNotNull,
Or<Exists<Select<SOOrderType,
Where<SOOrderType.orderType, Equal<SOOrder.orderType>,
And<SOOrderType.aRDocType, Equal<ARDocType.noUpdate>,
And<SOOrderType.behavior, Equal<SOBehavior.sO>>>>>>>>>>,
OrderBy<Desc<SOOrder.orderNbr>>>), Filterable = true)]
public virtual String OrderNbr
you can get some fields from the related Customer record, using Selector keyword
[PXFormula(typeof(Selector<
SOOrder.orderNbr,
Customer.consolidateStatements>))]
As a result, there are two possible solutions:
1) Rewrite SOOrder.OrderNbr selector declaration with your EDITran DAC
...
[SO.RefNbr(typeof(Search2<SOOrder.orderNbr,
LeftJoinSingleTable<Customer, On<SOOrder.customerID, Equal<Customer.bAccountID>,
And<Where<Match<Customer, Current<AccessInfo.userName>>>>>,
LeftJoin<EDITran, On<EDITran.doctype, Equal<SOOrder.orderType>,
And<EDITran.erprefnbr, Equal<SOOrder.orderNbr>>>>>,
Where<SOOrder.orderType, Equal<Optional<SOOrder.orderType>>,
And<Where<Customer.bAccountID, IsNotNull,
Or<Exists<Select<SOOrderType,
Where<SOOrderType.orderType, Equal<SOOrder.orderType>,
And<SOOrderType.aRDocType, Equal<ARDocType.noUpdate>,
And<SOOrderType.behavior, Equal<SOBehavior.sO>>>>>>>>>>,
OrderBy<Desc<SOOrder.orderNbr>>>), Filterable = true)]
public virtual String OrderNbr
Then it will be possible to get you field from there
[PXFormula(typeof(Selector<
SOOrder.orderNbr,
EDITran.sync>))]
2) Use PXDBScalar attribute to just get what you need. Note this will be a separate request to the database!!
...
[PXBool]
[PXDBScalar(typeof(Search<EDITran.sync,
Where<EDITran.doctype, Equal<SOOrder.orderType>,
And<EDITran.erprefnbr, Equal<SOOrder.orderNbr>>>>))]
public virtual bool? Sync
I'm not sure that's the right use of PXFormula. Here's the reference I normally use when I need to use PXFormula. See if it helps you simplify your PXFormula. You may need to simplify to a single Selector and define a foreign key to be able to complete your lookup.
Also, are you sure that the database contains the values that you expect? I often find that my problem is not where I think, and your issue may lie in setting the values or writing them to the database in your business logic.
It appears that you need the PXFormula to look to your EDITran table to find the record identified by the key (1st field specified in Selector) to then return back the value of the second field specified, which would reside in EDITran.
From Acumatica Developers Blog (AsiaBlog):
Selector
Selector does following:
Fetches a PXSelectorAttribute defined on the foreign key field (KeyField) of the current DAC.
Fetches the foreign data record currently referenced by the selector.
Using calculates and returns an expression on that data record as defined by ForeignOperand.
public class APVendorPrice : IBqlTable
{
// Inventory attribute is an aggregate containing a PXSelectorAttribute
// inside, which is also valid for Selector<>.
[Inventory(DisplayName = "Inventory ID")]
public virtual int? InventoryID
[PXFormula(typeof(Selector<
APVendorPrice.inventoryID,
InventoryItem.purchaseUnit>))]
public virtual string UOM { get; set; }
}
From that, I'd expect your PXFormula to look more like:
[PXFormula(typeof(Selector<
SOOrder.orderNbr,
EDITran.sync>))]
... assuming you have enough defined to tell Acumatica how to relate SOOrder.orderNbr to EDITran.erprefnbr.

Error: An error occurred during processing of the field Account Number: Error: 'Account Number' cannot be found in the system

The field that needs to save the record ID has an issue with resolving the autonumbering.
The DAC is set up to use autonumbering. However, when searching for a record or creating a new record, I get a 'The item AcctCD is not found (restricted:False,external:True,value: )' error
DAC:
[SerializableAttribute()]
[PXPrimaryGraph(typeof(LoanMaint))]
[PXCacheName("OLAccount")]
public class OLAccount : IBqlTable
{
[PXDBString(30, IsKey = true, IsUnicode = true, InputMask = ">CCCCCCCCCCCCCCC")]
[PXDefault()]
[PXUIField(DisplayName = "Loan Number", Visibility = PXUIVisibility.SelectorVisible, TabOrder = 1)]
[PXSelector(typeof(Search<OLAccount.acctCD>))]
[LoanAccount.RefNbr(typeof(Search2<OLAccount.acctCD,
InnerJoin<BAccountR, On<OLAccount.parentBAccountID, Equal<BAccountR.bAccountID>>>>),
Filterable = true, IsPrimaryViewCompatible = true)]
[LoanAccount.Numbering()]
public virtual string AcctCD { get; set; }
public abstract class acctCD : PX.Data.BQL.BqlString.Field<acctCD> { }
}
public class LoanAccount
{
/// <summary>
/// Specialized selector for OLAccount AcctCD.<br/>
/// By default, defines the following set of columns for the selector:<br/>
/// OLAccount.acctCD, OLAccount.acctName, OLAccount.externalAccountRef, <br/>
/// OLAccount.externalReference, OLAccount.parentBAccountID<br/>
/// </summary>
public class RefNbrAttribute : PXSelectorAttribute
{
public RefNbrAttribute(Type SearchType)
: base(SearchType,
typeof(OLAccount.acctCD),
typeof(OLAccount.acctName),
typeof(OLAccount.externalAccountRef),
typeof(OLAccount.parentBAccountID),
typeof(BAccountR.acctCD),
typeof(BAccountR.acctName),
typeof(BAccountR.type),
typeof(BAccountR.classID))
{
}
}
public class NumberingAttribute : AutoNumberAttribute
{
public NumberingAttribute()
: base(typeof(OLSetup.accountNumberingID), typeof(AccessInfo.businessDate)) { }
}
}
Graph:
public class LoanMaint : PXGraph<LoanMaint, OLAccount>
{
public PXSelect<OLAccount> LoanAccount;
public PXSelect<OLAccount, Where<OLAccount.acctCD, Equal<Current<OLAccount.acctCD>>>> CurrentLoanAccount;
public PXSetup<Company> Company;
public PXSetup<OLSetup> OLSetup;
public LoanMaint()
{
OLSetup setup = OLSetup.Current;
}
}
Error screen on system
I replicated this without receiving any errors.
Try this:
In the DAC definition, remove the PXSelector attribute (the selector is already being added by LoanAccount.RefNbr())
There is a mismatch between the field's length (30 chars) and the number of characters in the mask (only 15 "C" were added). Change the field's length to 15 (most of Acumatica auto-numbered fields support up to 15 chars)
If these changes still throw the error. To troubleshoot, simplify the code with:
a. Use an Acumatica numbering sequence: i.e. APSetup.batchNumberingID instead of OLSetup.accountNumberingID
b. Simplify the RefNbr() query to use a single table (or change it to a LeftJoin<> rather than an InnerJoin<>)
The issue was resolved by removing ReferentialIntegrity Attributes, refer to link form more information: https://asiablog.acumatica.com/2016/08/using-of-pxrestrictorattribute.html, the same error I was getting for no reason: It gives the uninformative message cannot be found in the system if a record with a given key does not meet the selector condition
I had a similar problem with PXSelectorAttribute, and PXRestrictors doesn't help.
Try to place your DAC's keys field in the same order as at database table constraint.
For example:
CONSTRAINT [SOLine_PK] PRIMARY KEY CLUSTERED
(
[CompanyID] ASC,
[OrderType] ASC,
[OrderNbr] ASC,
[LineNbr] ASC
)
in a DAC:
#region OrderType
...
#endregion
#region OrderNbr
...
#endregion
#region LineNbr
...
#endregion
It helps me in my case

Resources