Client has an Customised field called “Approval Type” on the Purchase Order Entry screen (screenshot attached). By Default this field is available when user creates an Order.
We are implementing the Approval Workflow for this client. The client wants that when a new PO is created, this field should be disabled. But once the PO is approved and user wants to make any change in the approved PO, On selecting “Hold” checkbox option, this field should be active and user should then be allowed to set any value from the field list and save the Order. I tried the Automation steps but could not figure out how to achieve it.
Many Thanks
In the rowselected event of the POOrder, add your conditions and use the PXUIFieldAttribute.SetVisible to hide/show your field.
It will be something like below.
protected virtual void POOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected del)
{
if (e.Row == null) return;
if (del != null) del(sender, e);
PXUIFieldAttribute.SetVisible<YOUR custom FIELD>(sender, e.Row, <Your true condition to show>);
}
Related
I would like to modify the ShippedQty field by putting the same value as the OpenOrderQty field after adding the line, but that does nothing. I removed the PXDefault. The value stay at 0.00.
protected void SOShipLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e, PXRowInserted InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOShipLine)e.Row;
if (row==null) {return;}
row.ShippedQty=row.OpenOrderQty;
}
Thanks.
Xavier
I would like to suggest you to not set the ShippedQty because it might have some implications as it is a calculated field. Instead, you can create a custom field and set the value of OpenOrderQty to that field.
When the RowInserted event is fired, the data has already been inserted into the cache so it's too late to try and edit the data. You should change this to use a RowInserting() event. See more details here
We have exposed CustomerID and Customer Location for TR order type, as standard Acumatica will not expose these fields. We have another custom screen which will be created before we create a shipment, so our custom screen will store these customer and customer location details for another purpose.
We are unable to create a shipment with the customer of type customer and vendor, it is allowing to create shipment only with company type customer. This is working in 2017R2 but not in 2019R1.
Here is the error message:
An error occurred during processing of the field Customer value C000000001 AR Error: Incorrect value specified. Specify a customer (for shipments of the Shipment type) or a company business account (for shipments of the Transfer type).
Sample code to make fields visible for TR Order Type also. I am trying this is fresh Acumatica instance with Sales data and without customizations published.
protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOOrder)e.Row;
if (row.OrderType == "TR")
{
PXUIFieldAttribute.SetVisible<SOOrder.customerID>(cache, (object)row, true);
PXUIFieldAttribute.SetVisible<SOOrder.customerLocationID>(cache, (object)row, true);
}
}
I have a checkbox on a DAC extension to the BAccount that I want to use to set a checkbox on Case when a customer is selected. Here is what the checkbox looks like on the Business Account screen.
Here is the field on the Case screen that I want to set when the customer is selected.
I found a stack overflow question where a couple of custom fields on a customer screen were to be copied to custom fields on a sales order. I have tried to substitute my fields into the code but I haven't been able to make it work.
Here is what I have tried. I'm not sure what I am missing.
protected void CRCase_CustomerID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
var crcase = e.Row as CRCase;
if (crcase.CustomerID != null)
{
var customer = PXSelectorAttribute.Select<CRCase.customerID>(sender, crcase) as BAccountR;
if (customer != null)
{
var customerExt = customer.GetExtension<BAccountExt>();
var crcaseExt = crcase.GetExtension<CRCaseExt>();
crcaseExt.UsrContractCustomer = customerExt.UsrSage100;
}
}
}
I do not understand why BAccountR is used instead of just BAccount. Neither works right now.
I solved the issue by combining are response I received on an earlier post. I modified the last two line as follows:
var customerExt = customer.GetExtension<BAccountExt>();
//var crcaseExt = crcase.GetExtension<CRCaseExt>();
//crcaseExt.UsrContractCustomer = customerExt.UsrSage100;
sender.SetValueExt<CRCaseExt.usrContractCustomer>(crcase, customerExt.UsrSage100 != null);
So here is the final issue that I need to resolve. The checkbox I used on the Business Account screen opens a new tab that displays custom fields. These custom fields are an extension of the BAccount DAC called DSDSage100. It is similar to the extension of the BAccount called Customer. In the DSDSage100 extension there is a field called UsrContractCustomer. That is the field that I want to read and set the Case field to the same value. Here is what the Sage 100 Tab looks like. I have a using directive for my project but I can't find the right reference to the DSDSage100 extension.
var customerExt = customer.GetExtension<DSDSage100>();
sender.SetValueExt<CRCaseExt.usrContractCustomer>(crcase, customerExt.UsrContractCustomer != null);
Acumatica provided the answer. While I "extended the BAccount DAC" with my custom table (DSDSage100, similar to the way Customer is an extension of the BAccount DAC), it is it's own DAC. The solution was:
DSDSage100 mydac = PXSelect<DSDSage100, Where<DSDSage100.bAccountID, Equal<Required<DSDSage100.bAccountID>>>>.Select(Base, crcase.CustomerID);
sender.SetValueExt<CRCaseExt.usrContractCustomer>(crcase, mydac.UsrContractCustomer != null);
Thanks for the help and support.
I have added a user defined checkbox UsrContractCustomer to CRCase. My first step is to try to set the checkbox when the user selects the Business Account (CustomerID).
Here is my latest attempt to set the checkbox.
protected void CRCase_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (CRCase)e.Row;
if (row.CustomerID != null)
{
//CRCaseExt rowExt = PXCache<CRCase>.GetExtension<CRCaseExt>(row);
CRCaseExt rowExt = row.GetExtension<CRCaseExt>();
rowExt.UsrContractCustomer = true;
}
}
On your field in your dac extension you should be able to use a formula to set the value. This will check or uncheck you field when the customer is entered or removed. Having the logic on the field also removes the need to write graph level changes such as events.
[PXFormula(typeof(IIf<Where<CRCase.customerID, IsNull>, False, True>))]
If you want to use the event as you have it I would try cache set value such as:
cache.SetValueExt<CRCaseExt.usrContractCustomer>(e.Row, row.CustomerID != null);
Brendan's solution is correct. In another post I retrieved the value that I wanted to use to set the user-defined field. The 'false' was replaced with a condition that sets the checkbox field.
sender.SetValueExt<CRCaseExt.usrContractCustomer>(crcase, false);
Thanks for the help and support.
I was wondering if anyone knew of a way to prevent certain fields from updating with default/stored data when updating the Customer field on the Sales Order page under a certain condition.
My Goal: When on the Sales Order page, if a certain Order Type is selected (in this case, the order type that signifies it is a Sales Order created and sent from our website), changing the Customer Field does not update/overwrite the Financial Settings or the Shipping Settings. This is because the Financial and Shipping settings fields are populated and sent from the website, and may have more specific information than the stored Customer information.
I want to keep the loading of default data for other tabs/fields, but keep the customer-entered billing and shipping info.
The SOOrder_CustomerID_FieldUpdated event on the sales order graph updates all related customer information based on the change of customer id. You can override it in a graph extension. The contact and address information is used as an ID to another table so all you need to do is keep the same contact or address ID. I tested the following graph extension and it seems to work by keeping the ID values before calling the base method.
public class SOOrderEntryMyExtension : PXGraphExtension<SOOrderEntry>
{
protected virtual void SOOrder_CustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated del)
{
var order = (SOOrder)e.Row;
var oldCustomerID = (int?)e.OldValue;
var orderBeforeBase = (SOOrder)cache.CreateCopy(order);
del?.Invoke(cache, e);
if (order == null || orderBeforeBase == null || oldCustomerID == null || order.CustomerID == oldCustomerID || order.OrderType != "WO")
{
return;
}
if (order.BillAddressID != orderBeforeBase.BillAddressID)
{
cache.SetValueExt<SOOrder.billAddressID>(order, orderBeforeBase.BillAddressID);
}
if (order.BillContactID != orderBeforeBase.BillContactID)
{
cache.SetValueExt<SOOrder.billContactID>(order, orderBeforeBase.BillContactID);
}
if (order.ShipAddressID != orderBeforeBase.ShipAddressID)
{
cache.SetValueExt<SOOrder.shipAddressID>(order, orderBeforeBase.ShipAddressID);
}
if (order.ShipContactID != orderBeforeBase.ShipContactID)
{
cache.SetValueExt<SOOrder.shipContactID>(order, orderBeforeBase.ShipContactID);
}
}
}