Execute PXAction after another action - acumatica

I add the autorun action "Maj BFT", but I Would like execute this action after the create IN document.
WHEN I use this code, the 2 actions are impacted.
I would like Wait 1000 only for genbft
public PXAction<POReceipt> Genbft;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Maj BFT",Enabled = true)]
protected virtual void genbft()
{
Task.Delay(1000).Wait();
}

Related

Mix Manual\Auto Numbering Sequences

In Numbering Sequences settings (CS201010), there is an option for manual numbering.
However, depending on the document type. There are instances where the reference number can be left blank. If it's blank, I'd want the auto numbering to kick in. Or something like call the NextNumber() function before saving the document. Is it possible ? How do I do that ?
At the moment, if I enforce the auto numbering. It doesn't allow me to type anything on the Reference number for example.
TIA
There are two ways: easy and little bit more complicated. Easy one will be attach to FieldDefaulting, and inside of that event check if that field is empty then assign some value into it.
Another way which better feet to Acumatica style is to implement your own AutoNumbering attribute and then apply that Autonumbering attribute to your DAC class. N.B. you can substitute Acumatica autonumbering attribute with yours with PXCacheExtension
below goes example of code with removing default autonumbering with implementing autonumbering via FieldDefaulting:
public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
[PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
[PXDefault]
[PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
//[ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
//[ARInvoiceType.Numbering]
//This is example of throwing away Acumatica autonumbering
//[ARInvoiceNbr]
[PXFieldDescription]
protected void ARInvoice_RefNbr_Cacheattached()
{
}
protected void ARInvoice_RefNbr_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
//here you can implement your way of initialization of this field
}
}
Or with attribute you can try something like this:
//somewhere in your code
public class RickAutonumberingAttribute : ARInvoiceNbrAttribute
{
//Here you'll need to play with implementation of your autonumbering
}
public class ARInvoiceEntryExt : PXGraphExtension<ARInvoiceEntry>
{
[PXDBString(15, InputMask = ">CCCCCCCCCCCCCCC", IsKey = true, IsUnicode = true)]
[PXDefault]
[PXUIField(DisplayName = "Reference Nbr.", TabOrder = 1, Visibility = PXUIVisibility.SelectorVisible)]
[ARInvoiceType.RefNbr(typeof(Search2<ARRegisterAlias.refNbr, InnerJoinSingleTable<ARInvoice, On<ARInvoice.docType, Equal<ARRegisterAlias.docType>, And<ARInvoice.refNbr, Equal<ARRegisterAlias.refNbr>>>, InnerJoinSingleTable<Customer, On<ARRegisterAlias.customerID, Equal<Customer.bAccountID>>>>, Where<ARRegisterAlias.docType, Equal<Optional<ARInvoice.docType>>, And2<Where<ARRegisterAlias.origModule, Equal<BatchModule.moduleAR>, Or<ARRegisterAlias.released, Equal<True>>>, And<Match<Customer, Current<AccessInfo.userName>>>>>, OrderBy<Desc<ARRegisterAlias.refNbr>>>), Filterable = true, IsPrimaryViewCompatible = true)]
//[ARInvoiceType.Numbering]
//This is example of throwing away Acumatica autonumbering
[RickAutonumberingAttribute]
[PXFieldDescription]
protected void ARInvoice_RefNbr_Cacheattached()
{
}
}

How do I implement presskey event in Acumatica?

I want to call SmartPanel to popup by press any keys.
Example: We click F3 in Selector Field. It'll popup search panel to select.
Could you please check my answer in another thread? You should have no problems utilizing PXButtonAttribute ShortcutChar property with an action opening popup.
For example, the following extension SOOrderEntry extension class will open Inventory Lookup on the Sales Order screen with the F2 key press:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> addInvBySite;
[PXUIField(DisplayName = "Add Stock Item", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton(ShortcutChar = (char)113)]
public virtual IEnumerable AddInvBySite(PXAdapter adapter)
{
return Base.addInvBySite.Press(adapter);
}
}

Default PO Type to 'Drop Ship' not working properly

I'm trying to default the OrderType.POOrderType to POOrderType.DropShip. I've tried altering the attributes in the customization manager to the following:
[PXDBString(2, IsKey = true, IsFixed = true)]
[PXDefault(POOrderType.DropShip)]
[POOrderType.List()]
[PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = true)]
[PX.Data.EP.PXFieldDescription]
But upon insertion of a new record, it does nothing. I've also tried using the CacheAttached event in a graph extension of POOrderEntry as follows:
public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
[PXDBString(2, IsKey = true, IsFixed = true)]
[PXDefault(POOrderType.DropShip)]
[POOrderType.List()]
[PXUIField(DisplayName = "Type", Visibility = PXUIVisibility.SelectorVisible, Enabled = true)]
[PX.Data.EP.PXFieldDescription]
protected virtual void POOrder_OrderType_CacheAttached(PXCache sender) { }
}
This also does NOT work.
I've finally tried using the RowInserting event as follows
protected virtual void POOrder_RowInserting(PXCache sender, PXRowInsertingEventArgs e)
{
POOrder poorder = (POOrder)e.Row;
if (poorder == null) return;
poorder.OrderType = POOrderType.DropShip;
}
This DOES default to DropShip, however, when I use the dropdown on the screen to change back to 'Normal', it empties all the fields, and the Type is also empty. If I select Normal again, then it displays the data in the fields correctly. I can't figure out what's going on here. I always have to select the Type twice to get anything to show. I can't see why the RowInserting event would cause this behavior...
There is POOrder_OrderType_FieldDefaulting event in the POOrderEntry, where default order type is set.
protected virtual void POOrder_OrderType_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
e.NewValue = POOrderType.RegularOrder;
}
It have 'higher priority' than PXDefault attribute (check T200 training for more information).
So you need to override this event handler.

Acumatica Extension on SOSitesStatusSelected

I've been having this problem on Acumatica extension for days now and can't seem to figure out the resolution. I've added an action on the Inventory Lookup Dialog of Sales Order screen (see screenshot below), the action is task to update the QtySelected to 1 and also to update my added Field which is the Brand to "testBrand". It is an extension of the SOSitesStatusSelected table, but whenever i clicked on the action, it only updates QtySelected and not my added Field Brand.
You may refer to my code below, thank you and I appreciate all the help.
//DAC
#region UsrBrand
[PXUIField(DisplayName = "Brand", Visible = true, Enabled = true)]
public virtual string UsrBrand{get;set;}
public abstract class usrBrand : IBqlField{}
#endregion
//BLC
public PXAction<PX.Objects.SO.SOOrder> updateAttributes;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Attributes")]
protected void UpdateAttributes()
{
this.Base.sitestatus.AllowInsert= true;
this.Base.sitestatus.AllowUpdate= true;
foreach (SOSiteStatusSelected line in this.Base.sitestatus.Select())
{
line.QtySelected = 1;
this.Base.sitestatus.Update(line);
SOSiteStatusSelectedExt rowExt = this.Base.sitestatus.Cache.GetExtension<SOSiteStatusSelectedExt>(line);
rowExt.UsrBrand = "testBrand";
this.Base.sitestatus.Cache.Update(rowExt);
}
}
In this case your extension SOSiteStatusSelectedExt is not a separate item. It's a part of the base record actually. So you don't need to update it separately.
line.QtySelected = 1;
SOSiteStatusSelectedExt rowExt = this.Base.sitestatus.Cache.GetExtension<SOSiteStatusSelectedExt>(line);
rowExt.UsrBrand = "testBrand";
this.Base.sitestatus.Update(line);

Print button on CR306000 to print case data

I have a custom button on CR306000 to try to print current loaded case information by calling one customized report. Navigation URL current set to:
~/Frames/ReportLauncher.aspx?ID=Inquirycase.rpx&CASEID=####
I will need to have custom programming to assign current case ID to replace "####", but don't know where and how to reference that custom button and modify its property. Please help. Thanks.
You could add a report parameter called 'CaseID' to your report and call it using the following code using an AEF extension like this:
public class CRCaseMaintExtension : PXGraphExtension<CRCaseMaint>
{
public override void Initialize()
{
base.Initialize();
//if adding to an existing menu button do that here...
// Example:
//Base.Inquiry.AddMenuAction(this.CustomReportButton);
}
public PXAction<CRCase> CustomReportButton;
[PXButton]
[PXUIField(DisplayName = "Custom Report", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual IEnumerable customReportButton(PXAdapter adapter)
{
if (Base.Case.Current != null)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["CaseID"] = Base.Case.Current.CaseID.ToString();
//enter in your report id/number here
string reportNumber = "Inquirycase";
//opens the report using the defined parameters
throw new PXReportRequiredException(parameters, reportNumber, "Custom Report");
}
return adapter.Get();
}
}
I have not tested the above but this should get you most of the way there.

Resources