Acumatica / problem updating a free field in a closed invoice - acumatica

When I update the usrDocCom field, I get the error message:
Error: Updating 'SO Invoice' record raised at least one error. Please review the errors. Error: 'Project' cannot be empty.
I tried to remove the controls from the project field, but without result
protected void ARTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ARTran) e.Row;
if (row != null )
{
PXUIFieldAttribute.SetEnabled(cache, row, false);
PXUIFieldAttribute.SetEnabled<ARTranExt.usrDocCom>(cache, row, true);
}
}
protected void ARInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ARInvoice)e.Row;
**Base.Transactions.Cache.AllowUpdate = true;** // permet de mettre à jour les informations libre des lignes
}
Thanks
Xavier

Two things...
be sure the project field has at least the non-project code assigned. Usually the value is represented by 'X'
it is recommended that you create a workflow and set the enabled property as true, in the Completed/Closed state of the invoice.

Related

Enabling Fields on Sales Order Screen

I need to enable fields on the Sales Order screen when the Status of the Sales Order is Completed.
I found a few other posts with solutions on older versions of Acumatica where you need to also change things in the Automation steps but in Version 21.207 Automation steps has been replaced with Workflows and I can't seem to edit them for the Sales Order screen.
My Code:
protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (SOOrder)e.Row;
if (row == null) return;
if (Condition1 != null && Condition2 == true)
{
cache.AllowUpdate = true;
Base.Document.Cache.AllowUpdate = true;
PXUIFieldAttribute.SetEnabled<SOOrder.salesPersonID>(cache, e.Row, true);
}
}
The Old Posts:
Enable SOLine field after Order Completed
How to enable CustomerOrderNbr field in Sales Order screen?
Update
Tried the answer from
Kyle Vanderstoep
But unfortunately the cache.AllowUpdate = true; stays False after stepping over it in debugging mode.
Update 2
The Solution from Kyle Vanderstoep did work in the end, after I remade the customization. Acumatica and my code was just acting up the first time round.
Two steps, override in workflow and in row selected. This one is for CustomerRefNbr
public override void Configure(PXScreenConfiguration configuration)
{
var context = configuration.GetScreenConfigurationContext<SOOrderEntry, SOOrder>();
context.UpdateScreenConfigurationFor(
c => c.WithFlows(flowContainer =>
{
flowContainer
.Update(SOBehavior.SO, df => df
.WithFlowStates(fls =>
{
fls.Update<SOOrderStatus.completed>(flsc => flsc
.WithFieldStates(fs => fs.AddField<SOOrder.customerRefNbr>()));
}));
}));
}
public virtual void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseN)
{
baseN(cache, e);
SOOrder doc = e.Row as SOOrder;
if (doc == null)
{
return;
}
cache.AllowUpdate = true;
PXUIFieldAttribute.SetEnabled<SOOrder.customerRefNbr>(cache, null, true);
}

make a tab disappear by code c# / or action disabled

I would like to make the activity tab disappear from the code (condition caseClassid)... Not having succeeded, I tried to make the actions inactive, I don't have any errors but it doesn't work, the screen is the CR306000, thank you ! Xavier FFY
public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
{
#region Event Handlers
protected void CRCase_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (CRCase)e.Row;
if (row == null) return;
Boolean xm_valfinale=true;
if ((row.CaseClassID=="F") ||(row.CaseClassID=="D"))
{
xm_valfinale=false;
PXUIFieldAttribute.SetWarning<CRCase.subject>(cache, row, "Il est nécessaire de renseigner la bonne famille !");
}
Base.Activities.AllowInsert = xm_valfinale;
Base.Activities.AllowUpdate = xm_valfinale;
Base.Activities.AllowDelete = xm_valfinale;
}
}
You need to use
Base.Activities.AllowSelect = xm_valfinale;
And on the PXTabItem in the ASPX, set
RepaintOnDemand="false"

Could someone help me on How to edit & Save a tracking number field on shipment screen even after shipment status is confirmed,completed or invoiced

Below is the code that i tried in ShipmentEntry graph extension but save button is not not enabled to save the new entry of tracking number also due to this code the entire row fields got enabled.
protected virtual void SOShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
{
if (BaseEvent != null)
BaseEvent(sender, e);
SOShipment row = e.Row as SOShipment;
if (row == null)
return;
PXUIFieldAttribute.SetEnabled<SOPackageDetailEx.trackNumber>(sender, row, true);
Base.Document.Cache.AllowUpdate = true;
Base.Packages.Cache.AllowUpdate = true;
}
protected virtual void SOPackageDetailEx_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
{
if (BaseEvent != null)
BaseEvent(sender, e);
SOPackageDetail row = e.Row as SOPackageDetail;
if (row == null) return;
PXUIFieldAttribute.SetEnabled<SOPackageDetailEx.trackNumber>(sender, row, true);
}
Thanks in advance for your help.
The code below edits and saves the tracking number field's value to the database even when the shipment is invoiced:
sOPackageDetailEx.TrackNumber = "Some Value";
Base.Packages.Update(sOPackageDetailEx);
Base.Caches[typeof(SOPackageDetailEx)].PersistUpdated(sOPackageDetailEx);
This code must be written in the SOShipmentEntry extension class, where sOPackageDetailEx is an instance of the 'SOPackageDetailEx' class.

Acumatica - POOrder_RowSelected override enabling field when Status is Pending approval

I am trying to enable a certain field when POOrder status is on "Pending Approval" like Description field but when I override it on POOrder_RowSelected event it still doesn't enable the field.
protected void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
POOrder row = (POOrder)e.Row;
if (row != null)
{
if (row.Hold == false && row.Status == POOrderStatus.Balanced) // Balance is indicated on Pending appoval
{
PXUIFieldAttribute.SetEnabled<POOrder.orderDesc>(cache, row, true);
}
}
}
You can accomplish this by using Automation Steps.
Select your Purchase Order screen, and on Step ID select "NL Pending Approval". (See below)
Then locate "Purchase Order" TableName with FieldName "*" and unchecked the Disabled box. Then Save your changes.
Then you can extend the POOrderEntry graph and on RowSelected event handler add your custom logic(and set enable the desired fields):
public void POOrder_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
POOrder order= (POOrder)e.Row;
if (order == null || Base.IsExport) return;
if (order.Status == POOrderStatus.Balanced)
{
PXUIFieldAttribute.SetEnabled<POLine.orderDesc>(sender, order, true);
}
}
Sample above would enable Description field when POOrder is with Balanced Status. Here is another link to similar question involving Custom User Fields: How to enable a custom field on PO301000 when the PO is in Open status?

Make Salesperson ID a Required field on SOLine

I need to make Salesperson ID on SOLine as a required field. But as Transfer orders do not have Salesperson, hence it should only validate when I create orders other than Transfer orders.
I tried with below code but it seems it is not working. Might be it is overrided with some existing code. Let me know if anyone has any suggestions.
public PXSetup<SOOrderTypeOperation,
Where<SOOrderTypeOperation.orderType, Equal<Optional<SOOrderType.orderType>>,
And<SOOrderTypeOperation.operation, Equal<Optional<SOOrderType.defaultOperation>>>>> sooperation;
protected bool IsTransferOrder
{
get
{
return (sooperation.Current.INDocType == INTranType.Transfer);
}
}
protected virtual void SOLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
var row = (SOLine)e.Row;
if (row == null) return;
PXDefaultAttribute.SetPersistingCheck<SOLine.salesPersonID>(sender, row, IsTransferOrder ? PXPersistingCheck.Nothing : PXPersistingCheck.Null);
}
I usually thrown an appropriate exception in Row Persisting when the condition exists.
Here is an example from SOShipmentEntry checking for transfer and checking the null value of a field:
protected virtual void SOShipment_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
SOShipment doc = (SOShipment)e.Row;
if (doc.ShipmentType == SOShipmentType.Transfer && doc.DestinationSiteID == null)
{
throw new PXRowPersistingException(typeof(SOOrder.destinationSiteID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOOrder.destinationSiteID).Name);
}
}
I have also called RaiseExceptionHandling similar to this example within RowPersisting
// sender = PXCache
if (row.OrderQty == Decimal.Zero)
sender.RaiseExceptionHandling<POLine.orderQty>(row, row.OrderQty, new PXSetPropertyException(Messages.POLineQuantityMustBeGreaterThanZero, PXErrorLevel.Error));
Both examples should stop the page from the save. calling the Raise Exception handling should point out the field with the Red X which is the better approach and easier for the user to find the field in question.
For your example:
protected virtual void SOLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
SOLine row = (SOLine)e.Row;
if (row == null)
{
return;
}
if (!IsTransferOrder && row.SalesPersonID == null)
{
sender.RaiseExceptionHandling<SOLine.salesPersonID>(row, row.SalesPersonID, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.Error));
}
}

Resources