Calculating Default Value in custom fields
I have several custom fields on my sales order form that I would like to populate default values. All three of the fields are date fields and would be default valued as follows:
Field 1-Default to Sales Order Request on Date (example 12/20/2018)
Field 2-Field 1 plus 7 days (Example 12/27/2018)
Field 3-Field 2 plus 14 days (Example 1/10/2019)
My initial thought was to try and get away with automation steps but this will only allow me to populate, not calculate a default. Whats the best method to achieve this?
I think you'd need a customization project for this, probably some C# code. Try posting this on StackOverflow. There are a lot of C# savvy people there.
Kevin - not sure if you were able to get this working or not. We did a very similar thing on the Purchase Order Promise Date field where is the PO was a drop ship we added 7 days to the date. I have attached a copy of the code as a reference for you.
//protected void POLine_PromistedDate_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
protected void POLine_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
POLine row = (POLine)e.Row;
if (row == null || row.PromisedDate == null)
SOLineSplit lineSplit = PXSelect<SOLineSplit, Where<SOLineSplit.pONbr, Equal<Current<POOrder.orderNbr>>, And<SOLineSplit.pOLineNbr, Equal<Required<POLine.lineNbr>>>>>
if (lineSplit != null)
SOLine soLine = PXSelect<SOLine, Where<SOLine.orderNbr, Equal<Required<SOLineSplit.orderNbr>>, And<SOLine.lineNbr, Equal<Required<SOLineSplit.lineNbr>>>>>
.Select(Base, lineSplit.OrderNbr, lineSplit.LineNbr);
if (Base.CurrentDocument.Current.OrderType == "DP")
soLine.ShipDate = row.PromisedDate;
soLine.ShipDate = Convert.ToDateTime(row.PromisedDate).AddDays(7);
Hope this helps.