Sales Order SOLines Conditionally Disabled tranDesc being overridden - acumatica

I have custom code on the Sales Order form that prevents editing SOLine descriptions unless it's a specific SOLine Code. I see that my custom code is being reached, but it seems that something else is overriding my logic, enabling editing on the field after I disable it. I was wondering if there are pre-defined automations that might be doing this for the Sales Order screen, or if there is some other place I should be looking to prevent this behavior.
//I had debug code that validated that RowSelected and SetEnabled were begin called
public class SOOrderEntry_Extension:PXGraphExtension
{
#region Event Handlers
protected void SOLine_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOLine)e.Row;
if(row != null && row.InventoryID.HasValue) {
//Only allow editing of parts description if the partno is 'NOTE'
InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(this.Base, row.InventoryID);
if(inventoryItem.InventoryCD == "NOTE") {
PXUIFieldAttribute.SetEnabled<SOLine.tranDesc>(cache, row, true);
} else {
PXUIFieldAttribute.SetEnabled<SOLine.tranDesc>(cache, row, false);
}
}
}
}

Unfortunately, your RowSelected handler will make no effect on the Line Description column because of how automation steps are configured for the Sales Orders screen:
In order to keep Line Description open for editing, you should change a number of Automation Steps disabling the entire Document Details grid on Sales Orders and subscribe to RowSelected handler for the SOOrder DAC to allow editing on the cache level for the SOOrder and SOLine DACs. Below are the changes required to enable Line Description for completed sales orders (if necessary, similar changes should be made to other Automation steps defined for the Sales Orders screen):
Subscribe to SOOrder_RowSelected handler to allow editing on the cache level for the SOOrder and SOLine DACs:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
SOOrder order = e.Row as SOOrder;
if (order != null && order.Status == SOOrderStatus.Completed)
{
sender.AllowUpdate = true;
Base.Transactions.Cache.AllowUpdate = true;
}
}
}
Modify Sales Orders' SO Completed automation step to open Line Description for editing. In addition to enabled Line Description, it's necessary to enable at least one of the SOOrder fields, otherwise the Save button will never become enabled for completed sales orders:

Related

Enable SOLine field after Order Completed

I need to enable the Salesperson ID and Commissionable fields of Sales Order Lines for Sales Orders in the Completed state.
I referenced the question here about enabling fields in the SOOrder header: How to enable CustomerOrderNbr field in Sales Order screen?
I added the two fields to the Automation Steps for the SO Complete step
And added customization code:
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
public void SOOrderLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
SOOrderLine line = e.Row as SOOrderLine;
if (line == null) return;
PXUIFieldAttribute.SetEnabled<SOOrderLine.salesPersonID>(sender, line, true);
PXUIFieldAttribute.SetEnabled<SOOrderLine.commissionable>(sender, line, true);
}
}
However, the fields are still disabled. Is there something I'm missing?
I have a similar requirement with one of my clients. You're on the right track with automation steps, but you need something else to enable editing. Here are the two event handlers we use:
protected void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
// Make the promised on ship date field editable even after the order has been completed.
// This code is not enough to make the feature work - automation steps need to be modified for SO Completed and SO Invoiced to ensure the
// caches are not disabled.
sender.AllowUpdate = true;
Base.Transactions.Cache.AllowUpdate = true;
}
protected void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
if (Base.Document.Current != null)
{
//Automation steps were modified to keep the transactions grid enabled for the completed status; we are manually disabling it here but leaving the promised on ship date field editable.
if(Base.Document.Current.Status == SOOrderStatus.Completed)
PXUIFieldAttribute.SetEnabled(sender, e.Row, false);
PXUIFieldAttribute.SetEnabled<SOLineExt.usrPromisedShipOnDate>(sender, e.Row, true);
PXUIFieldAttribute.SetEnabled<SOLineExt.usrLateReasonCode>(sender, e.Row, true);
}
}
To finish out the solution to this, in this case I found it was not necessary to Enable the full Sales Order Line via Automation Steps and then disable it via SOLine_RowSelect. It was, however, necessary to add the Sales Order > Order Nbr field to the automation steps (to make the document Save available after changing the Sales Order line). And strangely it was also necessary for us to give this Customization Project a higher Level than the others implementing it after other customizations that may have made changes to the same screen or objects.
public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
{
protected void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
sender.AllowUpdate = true;
Base.Transactions.Cache.AllowUpdate = true;
}
protected void SOLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
if (Base.Document.Current != null)
{
PXUIFieldAttribute.SetEnabled<SOLine.salesPersonID>(sender, e.Row, true);
PXUIFieldAttribute.SetEnabled<SOLine.commissionable>(sender, e.Row, true);
}
}
}

Sales Order status not changing after shipment created

I am creating shipment of type Transfer from the custom screen, using below code, shipment is creating successfully but status in Sales Order screen is not updating, and also it is not allowing me to create shipment from Sales Order screen again because it already has an open shipment.
The status is getting updated when I confirm shipment.
soShipmentGraph.CreateShipment(soOrderGraph.Document.Current, graph.Document.Current.SiteID, graph.Document.Current.ShipDate, false, SOOperation.Issue, created);
The status is updated towards the end of the CreateShipment method based on SOOrder.UpdateShipmentCntr field value if no exception were thrown during shipment creation:
if (order.OpenShipmentCntr > 0)
{
order.Status = SOOrderStatus.Shipping;
order.Hold = false;
soorder.Update(order);
}
The OpenShipmentCntr field is updated by the SOShipmentEntry.UpdateShipmentCntr method:
protected virtual void UpdateShipmentCntr(PXCache sender, object Row, short? Counter)
{
SOOrder order = (SOOrder)PXParentAttribute.SelectParent(sender, Row, typeof(SOOrder));
if (order != null)
{
order.ShipmentDeleted = (Counter == -1) ? true : (bool?)null;
order.ShipmentCntr += Counter;
if (((SOOrderShipment)Row).Confirmed == false)
{
order.OpenShipmentCntr += Counter;
}
soorder.Cache.SetStatus(order, PXEntryStatus.Updated);
}
}
When creating the shipment, SOShipmentEntry should insert a SOOrderShipment record that links SOOrder (Sales Order) with SOShipment (Shipment) records. The SOOrderShipment should be visible in the Orders tab of the shipment:
After insertion of the SOOrderShipment record the SOOrderShipment RowInserted event in SOShipmentEntry is raised:
protected virtual void SOOrderShipment_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
{
UpdateShipmentCntr(sender, e.Row, (short)1);
}
I couldn't determine the reason why the status won't change so I'd suggest to debug the steps leading to sales order status change.

Customer Order Required on Non-Transfer Orders

We have a simple customization that makes the Customer Order field required. But we do not know how to prevent the requirement on Transfer-type orders, which hides the Customer Order field. I found a similar article (Make Salesperson ID a Required field on SOLine) that discusses excluding a requirement for a "line" field, but I think this scenario (preventing requirement of Customer Order field for Transfer Sales orders) might be even simpler. Thanks for any help.
Change PXDefaultAttribute/PXUIFieldAttribute based on your business rules in SOOrder RowSelected event handler of SOOrderEntry graph extension:
public class SOOrderEntry_Extension:PXGraphExtension<SOOrderEntry>
{
protected void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
SOOrder soOrder = e.Row as SOOrder;
if (soOrder != null)
{
bool isRequired = (soOrder.OrderType != SOOrderTypeConstants.TransferOrder);
PXDefaultAttribute.SetPersistingCheck<SOOrder.customerOrderNbr>(sender,
soOrder,
isRequired ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
PXUIFieldAttribute.SetRequired<SOOrder.customerOrderNbr>(sender, isRequired);
}
}
}

How to enable a custom field on PO301000 when the PO is in Open status?

I have added a customization to the PO Entry screen, PO.30.10.00. The customization adds four date fields, a combobox text field, and a string(10) field.
Right now, the fields are only editable when the PO is on hold. The user wants to be able to edit these fields at any time. They are using these fields to keep track of different POs and will build Generic Inquiries on them so they can communicate the statuses of the POs by maintaining these fields.
The Promise Date is editable when the PO is in Open status. We would like these custom fields to be editable like the Promise Date is.
The Purchase Orders screen is heavily driven by Automation Steps. This fact makes changes to automation steps a mandatory step needed to enable a custom field when the PO is in Open status:
To enable Custom Text Fields on the Purchase Order Summary area and the Document Details grid, one should modify the NL Open step by adding 2 lines as shown in the screenshot above.
After you added those lines, Custom Text Field becomes editable on the Purchase Order Summary area, however, the Custom Text Field column is still read-only in the Document Details grid because of how POLine_RowSelected handler is implemented in the POOrderEntry BLC:
[Serializable]
public class POOrderEntry : PXGraph<POOrderEntry, POOrder>, PXImportAttribute.IPXPrepareItems
{
...
protected virtual void POLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
POLine row = (POLine)e.Row;
POOrder doc = this.Document.Current;
if (row == null) return;
if (IsExport) return;//for performance
bool isLinkedToSO = row.Completed == true && IsLinkedToSO(row);
if (this.Document.Current.Hold != true || isLinkedToSO)
{
PXUIFieldAttribute.SetEnabled(sender, e.Row, false);
...
}
...
}
...
}
To enable the Custom Text Field column for editing, you should additionally subscribe to POLine_RowSelected handler within your POOrderEntry BLC extension as shown in the code snippet below:
public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
public void POLine_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
POLine line = (POLine)e.Row;
POOrder order = Base.Document.Current;
if (order == null || line == null || Base.IsExport) return;
if (order.Status == POOrderStatus.Open)
{
PXUIFieldAttribute.SetEnabled<POLineExt.usrCustomTextField>(sender, line, true);
}
}
}
Once you made changes in Automation Steps and subscribed to POLine_RowSelected handler within a POOrderEntry BLC extension your custom fields on both the Purchase Order Summary area and the Document Details grid should be open for editing when the PO is in Open status:

How to enable CustomerOrderNbr field in Sales Order screen?

In Sales Order screen, I'm trying to enable the CustomerOrderNbr field if the status is completed
protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
SOOrder doc = e.Row as SOOrder;
if (doc == null)
{
return;
}
if (doc.Completed == true )
{
PXUIFieldAttribute.SetEnabled(cache, doc , true);
PXUIFieldAttribute.SetEnabled<SOOrder.customerOrderNbr>(cache, doc, true);
}
}
however, it remains disabled and not doing what it's supposed to do. So what am I doing wrong ? Am I on the right event to override at all ?
Or is the screen really locked in once the Sales Order is Completed ?
Thanks for any answers.
Since Sales Orders screen is heavily driven by Automation Steps, in addition to extended RowSelected handler for the SOOrder DAC, it's an absolute must to modify automation steps for Completed orders that disable entire SOOrder :
In addition to the automation step change shown above, you should keep SOOrder_RowSelected handler:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public void SOOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
SOOrder order = e.Row as SOOrder;
if (order == null) return;
if (order.Completed == true)
{
PXUIFieldAttribute.SetEnabled<SOOrder.customerOrderNbr>(sender, order, true);
}
}
}
With those 2 changes in place, Customer Order will stay enabled for SO Orders with Completed status:

Resources