I'm a bit lost here on what approach to take to get an aggregate value from my usr field on SOLineExt. My goal is a simple aggregation of the user field which is based on a this value from the SOLine:
itemExt.UsrMinutes * (int)row.OrderQty;
In the SOLineExt the value above is stored in UsrMultByQuant it gets the value fine but I can't seem to aggregate the the SOLineExt value to get the total of the UsrMultByQuant into my SOOrder field called UsrTotalWorkMinutes
[PXDBInt]
[PXUIField(DisplayName="TotalWorkMinutes")]
[PXFormula(null, typeof(SumCalc<SOLineExt.usrMultByQuant>))]
public virtual int? UsrTotalWorkMinutes{get;set;}
public abstract class usrTotalWorkMinutes : IBqlField{}
I was referencing T200 Lesson 7, also I attempted to implement a fieldselecting (as instructed on Lesson 11.8 in t300) to try that approach for getting my total usr field value from the SOLineExt table with no success.
Any advice is appreciated, Thank you
Edit:
I removed the null from the PXformula and i am receiving this error now.
I also modified the dac slightly to have the PXParent attribute to select the current SOLine
[PXDBInt]
[PXUIField(DisplayName="TotalWorkMinutes")]
[PXFormula(typeof(SumCalc<SOLineExt.usrMultByQuant>))]
[PXParent(typeof(Select<SOLine,
Where<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>))]
public virtual int? UsrCuryWorkMinutes{get;set;}
public abstract class usrCuryWorkMinutes : IBqlField{}
Still does not total my SOLineExt value and I am recieving the error above when null removed.
The 2 extension classes from below should be enough to achieve the requested behavior (notice, fields UsrCuryWorkMinutes and UsrMultByQuant are of the decimal type):
public class SOOrderExt : PXCacheExtension<SOOrder>
{
public abstract class usrCuryWorkMinutes : IBqlField { }
[PXDBDecimal(2)]
[PXUIField(DisplayName = "Total Work Minutes")]
public virtual decimal? UsrCuryWorkMinutes { get; set; }
}
public class SOLineExt : PXCacheExtension<SOLine>
{
public abstract class usrMinutes : IBqlField { }
[PXDBInt]
[PXUIField(DisplayName = "Work Minutes")]
public virtual int? UsrMinutes { get; set; }
public abstract class usrMultByQuant : IBqlField { }
[PXDBDecimal(2)]
[PXUIField(DisplayName = "Total Work Minutes", Enabled = false)]
[PXFormula(typeof(Mult<IsNull<SOLine.orderQty, decimal0>, SOLineExt.usrMinutes>),
typeof(SumCalc<SOOrderExt.usrCuryWorkMinutes>))]
public virtual decimal? UsrMultByQuant { get; set; }
}
There is no need for PXParentAttribute in SOLineExt because of the original SOLine.OrderNbr field already decorated with PXParentAttribute to aggregated other values from SOLine to SOOrder:
[System.SerializableAttribute()]
[PXCacheName(Messages.SOLine)]
public partial class SOLine : PX.Data.IBqlTable, ILSPrimary, IDiscountable, ISortOrder
{
...
#region OrderNbr
public abstract class orderNbr : PX.Data.IBqlField
{
}
protected String _OrderNbr;
[PXDBString(15, IsUnicode = true, IsKey = true, InputMask = "")]
[PXDBDefault(typeof(SOOrder.orderNbr), DefaultForUpdate = false)]
[PXParent(typeof(Select<SOOrder, Where<SOOrder.orderType, Equal<Current<SOLine.orderType>>, And<SOOrder.orderNbr, Equal<Current<SOLine.orderNbr>>>>>))]
[PXUIField(DisplayName = "Order Nbr.", Visible = false, Enabled = false)]
public virtual String OrderNbr
{
...
}
#endregion
...
}
Related
I have a very simple Maint page, it has no events
public PXCancel<RCDistributorSalesStat> Cancel;
public PXSave<RCDistributorSalesStat> Save;
public SelectFrom<RCDistributorSalesStat>.View Records;
and everytime I save the first record entered I get an error and it has added a second blank line and throws errors that required fields are missing.
I found a similar question to this on here about having multiple ISKey set, though I only have one.
#region DistributorSalesStatID
[PXDBIdentity(IsKey = true)]
public virtual int? DistributorSalesStatID { get; set; }
public abstract class distributorSalesStatID : PX.Data.BQL.BqlInt.Field<distributorSalesStatID> { }
#endregion
#region InventoryID
[StockItem(Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(InventoryItem.inventoryCD), Enabled = true)]
[PXRestrictor(typeof(Where<InventoryItem.baseUnit.IsEqual<BQLConstants.Straw>>), null)]
[PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
public virtual int? InventoryID { get; set; }
public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
#endregion
#region StatisticDate
[PXDBDate()]
[PXUIField(DisplayName = "Statistic Date")]
public virtual DateTime? StatisticDate { get; set; }
public abstract class statisticDate : PX.Data.BQL.BqlDateTime.Field<statisticDate> { }
#endregion
#region CustomerID
[CustomerActive(
//typeof(Search<BAccountR.bAccountID, Where<True, Equal<True>>>),
Visibility = PXUIVisibility.SelectorVisible,
DescriptionField = typeof(Customer.acctName),
Filterable = true) ]
//[CustomerOrOrganizationInNoUpdateDocRestrictor]
[PXForeignReference(typeof(Field<RCDistributorSalesStat.customerID>.IsRelatedTo<PXAccess.BAccount.bAccountID>))]
public virtual int? CustomerID { get; set; }
public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }
#endregion
#region CustomerLocationID
[LocationActive(typeof(Where<Location.bAccountID, Equal<Current<customerID>>,
And<MatchWithBranch<Location.cBranchID>>>),
DescriptionField = typeof(Location.descr),
Visibility = PXUIVisibility.SelectorVisible)]
[PXDefault(typeof(Coalesce<Search2<BAccountR.defLocationID,
InnerJoin<CRLocation, On<CRLocation.bAccountID, Equal<BAccountR.bAccountID>, And<CRLocation.locationID, Equal<BAccountR.defLocationID>>>>,
Where<BAccountR.bAccountID, Equal<Current<customerID>>,
And<CRLocation.isActive, Equal<True>,
And<MatchWithBranch<CRLocation.cBranchID>>>>>,
Search<CRLocation.locationID,
Where<CRLocation.bAccountID, Equal<Current<customerID>>,
And<CRLocation.isActive, Equal<True>, And<MatchWithBranch<CRLocation.cBranchID>>>>>>))]
[PXForeignReference(
typeof(CompositeKey<
Field<customerID>.IsRelatedTo<Location.bAccountID>,
Field<customerLocationID>.IsRelatedTo<Location.locationID>
>))]
public virtual int? CustomerLocationID { get; set; }
public abstract class customerLocationID : PX.Data.BQL.BqlInt.Field<customerLocationID> { }
#endregion
#region SalesAmount
[PXDBDecimal()]
[PXUIField(DisplayName = "Sales Amount")]
public virtual Decimal? SalesAmount { get; set; }
public abstract class salesAmount : PX.Data.BQL.BqlDecimal.Field<salesAmount> { }
#endregion
#region SalesUnits
[PXDBInt()]
[PXUIField(DisplayName = "Sales Units")]
public virtual int? SalesUnits { get; set; }
public abstract class salesUnits : PX.Data.BQL.BqlInt.Field<salesUnits> { }
#endregion
#region QuantityOnHand
[PXDBInt()]
[PXUIField(DisplayName = "Quantity On Hand")]
public virtual int? QuantityOnHand { get; set; }
public abstract class quantityOnHand : PX.Data.BQL.BqlInt.Field<quantityOnHand> { }
#endregion
I am unsure what is causing the unwanted row to try and persist.
I have changed my keys around, I removed my IsKey on the PXDBIdentity and set two other fields as the key in the DAC and the DB. That seems to have the desired effect as no blank row gets created during Save. Upon further testing it appears that for our listview page I was missing "px:Selector" rows inside of my RowTemplate in my Grid.
I have a customization to the Bills and Adjustments screen (AP301000), where I'm simply adding 4 user fields to the Document Details tab's grid. I've done this many, many times in the past and I've never seen this error. I have absolutely NO idea what would cause it.
Here's the DAC extension:
[PXCacheName("AP Tran Extension")]
public class APTranExt : PXCacheExtension<APTran>
{
#region UsrACAllocModule
[PXDBString(30, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Allocation Module")]
public virtual string UsrACAllocModule { get; set; }
public abstract class usrACAllocModule : PX.Data.BQL.BqlString.Field<usrACAllocModule> { }
#endregion
#region UsrACAllocBatch
[PXDBString(30, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Allocation Batch")]
public virtual string UsrACAllocBatch { get; set; }
public abstract class usrACAllocBatch : PX.Data.BQL.BqlString.Field<usrACAllocBatch> { }
#endregion
#region UsrACAllocLineNbr
[PXDBInt()]
[PXUIField(DisplayName = "Allocation LineNbr")]
public virtual int? UsrACAllocLineNbr { get; set; }
public abstract class usrACAllocLineNbr : PX.Data.BQL.BqlInt.Field<usrACAllocLineNbr> { }
#endregion
#region UsrACAllocationID
[PXDBString(30, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Allocation ID")]
public virtual string UsrACAllocationID { get; set; }
public abstract class usrACAllocationID : PX.Data.BQL.BqlString.Field<usrACAllocationID> { }
#endregion
}
The database fields exist as follows:
Here is how the fields are added:
And here is the error:
We ran across the same issue. It is a bug in Acumatica. It is resolved in build 20.104.
I have a grid embedded in a popup that stores user selected items from another grid. The user highlights the desired row, clicks a button, and it is added as a new row in the grid based on the information of the highlighted row. For some reason, it is not adding a new row, but instead it is overwriting the current one:
Adding new row for the first time:
Trying to add second row:
The first image I selected to add a new row the first time. The second image shows that when I add a second row, it overwrites the current row instead of inserting a new row. I tried to do this whole process at first with a PXFilter and found that PXFilters only allow for one row to be stored. I then created a blank table of the same name as the filter with all of the fields, changed the view to PXSelect, and thought it might be that, but it didn't fix it.
The code for the Add to MTO button is:
public PXAction<PMProject> addToMTO;
[PXUIField(DisplayName = "Add to MTO")]
[PXButton]
protected virtual void AddToMTO()
{
SOSiteStatusSelected row = sitestatus.Current;
if (row == null)
return;
bool isMade = false;
//NOTE: If you have a more efficient method to check if a view contains a row, please include that in the answer.
foreach (MTOLSelected testLine in SelectedItems.Select())
{
if (testLine.ItemID == row.InventoryID)
{
isMade = true;
break;
}
}
if (!isMade)
{
MTOLSelected line = new MTOLSelected();
SelectedItems.Insert(line);
line.ItemID = row.InventoryID;
line.ItemCD = row.InventoryCD;
line.Price = row.CuryUnitPrice;
line.Descr = row.Descr;
SelectedItems.Update(line);
}
else
{
SelectedItems.Ask("This item is already moved into the MTO List", MessageButtons.OK);
}
}
The DAC is:
[Serializable]
public class MTOLSelected : IBqlTable
{
[PXDBIdentity]
[PXUIField(DisplayName = "MTOLID")]
public int? Id { get; set; }
public abstract class id : IBqlField { }
//Might more Drawing Number and Qty Required to this new table
#region ItemID
[PXDBInt()]
[PXUIField(DisplayName = "ID")]
public virtual int? ItemID { get; set; }
public abstract class itemID : IBqlField { }
#endregion
#region ItemCD
[PXDBString(15)]
[PXUIField(DisplayName = "Item CD")]
public virtual string ItemCD { get; set; }
public abstract class itemCD : IBqlField { }
#endregion
#region Descr
[PXDBString(255)]
[PXUIField(DisplayName = "Desc")]
public virtual string Descr { get; set; }
public abstract class descr : IBqlField { }
#endregion
#region Qty
[PXDBInt()]
[PXUIField(DisplayName = "Qty")]
public virtual int? Qty { get; set; }
public abstract class qty : IBqlField { }
#endregion
#region Price
[PXDBDecimal()]
[PXUIField(DisplayName = "Price")]
public virtual decimal? Price { get; set; }
public abstract class price : IBqlField { }
#endregion
#region Length
[PXDBDecimal()]
[PXUIField(DisplayName = "Length")]
public virtual decimal? Length { get; set; }
public abstract class length : IBqlField { }
#endregion
#region Feet
[PXDBInt()]
[PXUIField(DisplayName = "Feet")]
public virtual int? Feet { get; set; }
public abstract class feet : IBqlField { }
#endregion
#region Inches
[PXDBDecimal()]
[PXUIField(DisplayName = "Inches")]
public virtual decimal? Inches { get; set; }
public abstract class inches : IBqlField { }
#endregion
}
Your DAC appears to need IsKey on the Identity field: [PXDBIdentity(IsKey=true)]
I'm trying to populate this field with the value of a customer attribute.
public class CustomerExt : PXCacheExtension<Customer>
{
#region OtherID
[PXString]
[PXUIField(DisplayName = "Other ID")]
[PXDBScalar(typeof(Search<CSAnswers.value,
Where<CSAnswers.refNoteID, Equal<Current<Customer.noteID>>,
And<CSAnswers.attributeID, Like<OtherIDAttr>>>>))]
public virtual string UsrOtherID { get; set; }
public abstract class usrOtherID : IBqlField { }
#endregion
public class OtherIDAttr: Constant<string>
{
public OtherIDAttr() : base("OTHERID") { }
}
}
It causes the above error when the field is added to a screen. If I remove the second condition from the Search<>, the field populates, so I'm sure its the comparison between the CSAnswers AttributeID and the constant string.
If someone could point me in the right direction, that would be awesome.
Looks like you get this error due to the Current operator (Equal<Current<Customer.noteID>>) used within PXDBScalarAttribute.
Attempt to simply remove the Current operator led to a different error Invalid column name 'NoteID'., which can be resolved by the replacement of Customer.noteID with PX.Objects.CR.BAccount.noteID:
public class CustomerExt : PXCacheExtension<Customer>
{
#region OtherID
public abstract class usrOtherID : IBqlField { }
[PXString]
[PXUIField(DisplayName = "Other ID")]
[PXDBScalar(typeof(Search<CSAnswers.value,
Where<CSAnswers.refNoteID, Equal<BAccount.noteID>,
And<CSAnswers.attributeID, Like<OtherIDAttr>>>>))]
public virtual string UsrOtherID { get; set; }
#endregion
public class OtherIDAttr : Constant<string>
{
public OtherIDAttr() : base("OTHERID") { }
}
}
I have a custom processing page. The main DAC of the data view is ARRegister, but there is the data view delegate. Both the view & delegate join ARCashSale & ARInvoice to the main DAC, The reason for this is...some records are cash sales, and others are invoices, overdue charges, ect. A few grid columns are included, which displays data specific to a cash sale. I invoke a static method in my process graph to assign the process delegate. The method runs with no errors.
In the data view delegate, I check the doc type for each record returned from the BQL.
If cash sale, then
yield return new PXResult<ARRegister, ARCashSale>(register, cashsale)
ELSE
yield return new PXResult<ARRegister>(register)
The reason for the delegate is to check some other conditions which cannot be determined using standard BQL. I notice the data in the column specific to a cash sale disappears after the user selects 'Process All'. I am unable to determine the reason. Checking to see if others have experienced this.
DataView
public PXProcessingJoin<ARRegister,
LeftJoin<cs.ARCashSale, On<ARRegister.docType, Equal<cs.ARCashSale.docType>, And<ARRegister.refNbr, Equal<cs.ARCashSale.refNbr>>>,
LeftJoin<ARInvoice, On<ARRegister.docType, Equal<ARInvoice.docType>, And<ARRegister.refNbr, Equal<ARInvoice.refNbr>>>,
InnerJoin<Customer,On<ARRegister.customerID,Equal<Customer.bAccountID>>>>>,
Where2<Where<ARRegister.released, Equal<True>, And<ARRegister.branchID, Equal<Current<AccessInfo.branchID>>>>,
And<Where<Customer.finChargeApply,Equal<True>>>>> Registers;
This is an older question, but I had a similar issue.
You need to add a boolean field named "Selected" to DACs you want to process.
The way I solved it was using a local DAC.
You can make it inherit from ARRegister and just add the required field.
In my case I used PXProjection, inherited from the main DAC and added the fields I needed from the joined DACs. Note that you need to add the BqlField = typeof(DAC.field) property to the type attribute of these fields to map them to the correct DAC.
Then in the PXProcessing view you just use your local DAC.
Also, it is very useful to try the Request Profiler screen (SM205070) when troubleshooting BQL.
Basically in processing screens sub DAC (other than Main DAC in view), filed values will not persist once the process completed.
In this case, the PXProjection will help us to persist the values even after completion of the process for the rows/records in processing screens.
Please find the sample Projection View and DAC below.
[PXProjection(typeof(Select2<SOShipment, InnerJoin<SOOrderShipment,
On<SOOrderShipment.shipmentNbr, Equal<SOShipment.shipmentNbr>,
And<SOShipment.status, Equal<SOShipmentStatus.confirmed>>>,
InnerJoin<SOOrder, On<SOOrderShipment.orderType, Equal<SOOrder.orderType>,
And<SOOrderShipment.orderNbr, Equal<SOOrder.orderNbr>>>>>>))]
Projection DAC:
[Serializable]
public class ProjectionShipmentDAC : IBqlTable
{
#region Selected
public abstract class selected : IBqlField
{
}
protected bool? _Selected = false;
[PXBool]
[PXDefault(false, PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Selected")]
public virtual bool? Selected
{
get
{
return _Selected;
}
set
{
_Selected = value;
}
}
#endregion
#region Status
[PXDBString(1, IsFixed = true, BqlField = typeof(SOShipment.status))]
[PXUIField(DisplayName = "Status")]
[SOShipmentStatus.List()]
public virtual string Status { get; set; }
public abstract class status : IBqlField { }
#endregion
#region ShipmentNbr
[PXDBString(15, IsKey = true, IsUnicode = true, BqlField = typeof(SOShipment.shipmentNbr))]
[PXUIField(DisplayName = "Shipment Nbr.")]
public virtual string ShipmentNbr { get; set; }
public abstract class shipmentNbr : IBqlField { }
#endregion
#region ShipDate
[PXDBDate(BqlField = typeof(SOShipment.shipDate))]
[PXUIField(DisplayName = "Shipment Date")]
public virtual DateTime? ShipDate { get; set; }
public abstract class shipDate : IBqlField { }
#endregion
#region CustomerID
[PXDBInt(BqlField = typeof(SOShipment.customerID))]
[PXUIField(DisplayName = "Customer")]
[PXSelector(typeof(Customer.bAccountID), new Type[] { typeof(Customer.acctCD), typeof(Customer.acctName) },
SubstituteKey = typeof(Customer.acctCD), DescriptionField = typeof(BAccount.acctName))]
public virtual int? CustomerID { get; set; }
public abstract class customerID : IBqlField { }
#endregion
#region Shipped Quantity
[PXDBDecimal(BqlField = typeof(SOShipment.shipmentQty))]
[PXUIField(DisplayName = "Shipped Quantity")]
public virtual decimal? ShipmentQty { get; set; }
public abstract class shipmentQty : IBqlField { }
#endregion
}
Have you played around with MatrixMode and/or SyncPosition on your page grid? You might need SyncPosition="True"
Also, does the issue occur if not using process all? (process 1 or 2 rows)