Event with DAC SMEmail - acumatica

Impossible to do this event when we receive email.
this event works when you create the email manually
protected void SMEmail_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
{
var row = (SMEmail)e.Row;
cache.SetValueExt<SMEmail.subject>(row, row.Subject+"/INS");
Base.Actions.PressSave();
}
or
protected void SMEmail_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
{
var row = (SMEmail)e.Row;
row.subject+=row.Subject+"/INS";
}
What even we can use when acumatica receipt automatic email.
Xavier

Related

Pricing initialization in SOline dac

I am looking for the best possibility to initialize the tarifs.
using the fielddefaulting event, the amount stays at 0
protected void SOLine_CuryUnitPrice_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
var row = (SOLine)e.Row;
SOOrder order = (SOOrder) Base.Document.Current;
BAccount un_compte=PXSelect<BAccount , Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(this.Base,row.CustomerID);
if (row.InventoryID!=null)
{
InventoryItem un_article=PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>>.Select(this.Base,row.InventoryID);
string taxe=Convert.ToString(order.TaxCalcMode);
if ((un_compte!=null) && (un_article!=null))
{
if ((un_compte.GetExtension<BAccountExt>().Usrcattarifaireclient=="cat1") && (taxe=="N"))
{
decimal? tmp=un_article.GetExtension<InventoryItemExt>().Usrprxht1;
e.NewValue=tmp;
}
if ((un_compte.GetExtension<BAccountExt>().Usrcattarifaireclient=="cat1") && (taxe=="G"))
{
decimal? tmp=un_article.GetExtension<InventoryItemExt>().Usrprxttc1;
e.NewValue=tmp;
}
}
}
}
I finally used the event : SOLine_UOM_FieldUpdated.
Everything works perfectly, including the webservices
protected void SOLine_UOM_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
var row = (SOLine)e.Row;
row.CuryUnitPrice=tmp;
}

How can I default a field (A) to a value of a field (B) and still be able to edit the field and backdate?

Application Date to default Document Date:
protected void ARPayment_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ARPayment)e.Row;
if (row != null)
{
row.AdjDate = row.DocDate;
row.AdjFinPeriodID = row.FinPeriodID;
}
}
The code defaults the fields as required but Application date cannot be edited hence backdating cannot be done
protected void ARPayment_AdjFinPeriodID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
var row = (ARPayment)e.Row;
row.AdjFinPeriodID = row.FinPeriodID;
}
protected void ARPayment_AdjDate_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
var row = (ARPayment)e.Row;
row.AdjDate = row.DocDate;
}
Using field defaulting gives index out of range error
By Adding a condition to check the status of the document it seizes to work
protected void ARPayment_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (ARPayment)e.Row;
if (row != null && row.Status == "Open")
{
row.AdjDate = row.DocDate;
row.AdjFinPeriodID = row.FinPeriodID;
}
}
The RowSelected event is not an initialization event. It is run on every callback to the server.
The FieldDefaulting event should assign the default value using the NewValue property of PXFieldDefaultingEventArgs argument parameter.
Using field defaulting gives index out of range error
That should not happen in your FieldDefaulting handler because there are no index access operations. I can't reproduce this issue. Remove all other customization code, keep only the FieldDefaulting event and this error should disappear.
There is another issue though. The DocDate value is always null when I debug the FieldDefaulting event. When I pass a valid Date value for initialization it does work as expected on new payments. Example:
using PX.Data;
using System;
namespace PX.Objects.AR
{
public class ARPaymentEntry_Extension : PXGraphExtension<ARPaymentEntry>
{
public void ARPayment_AdjDate_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
ARPayment row = e.Row as ARPayment;
if (row != null)
e.NewValue = new DateTime(2077, 01, 01);
}
}
}

Action button not not updating on screen

I have an action button on the QuoteMaint graph. This action is in the actions folder. I set whether or not the button is enabled based on the quote status. When the user submits the quote, the action button should be enabled. I stepped through the code and it runs the routine to enable button, but on the screen it is not enabled. When I refresh the screen it is enabled with no issues. The code is below, thanks for your help!
public PXAction<CRQuote> printQuoteSummary;
[PXButton(CommitChanges = true, SpecialType = PXSpecialButtonType.Report)]
[PXUIField(DisplayName = "Print Quote - Summary")]
public IEnumerable PrintQuoteSummary(PXAdapter adapter)
{
Dictionary<string, string> parameters = new Dictionary<string, string>();
string actualReportID = "CR604510";
foreach (CRQuote item in adapter.Get<CRQuote>())
{
parameters[nameof(CRQuote.OpportunityID)] = item.OpportunityID;
parameters[nameof(CRQuote.QuoteNbr)] = item.QuoteNbr;
throw new PXReportRequiredException(parameters, actualReportID, "Report " + actualReportID);
}
return adapter.Get();
}
public override void Initialize()
{
base.Initialize();
Base.actionsFolder.AddMenuAction(printQuoteSummary);
Base.Actions.Move("PrintQuote", "printQuoteSummary");
printQuoteSummary.SetEnabled(Base.Quote.Current?.Status == CRQuoteStatusAttribute.Approved || Base.Quote.Current?.Status == CRQuoteStatusAttribute.Sent);
}
protected virtual void CRQuote_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
CRQuote quote = e.Row as CRQuote;
if (quote == null) return;
using (new PXConnectionScope())
{
CalcTotals(quote);
}
printQuoteSummary.SetEnabled(quote.Status == CRQuoteStatusAttribute.Approved || quote.Status == CRQuoteStatusAttribute.Sent);
}
Adding the additional argument for the event delegate resolved the issue in testing, please find sample below.
protected virtual void CRQuote_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected del)
{
del?.Invoke(cache, e);
CRQuote quote = e.Row as CRQuote;
if (quote == null) return;
using (new PXConnectionScope())
{
CalcTotals(quote);
}
PrintQuoteSummary.SetEnabled(quote.Status == CRQuoteStatusAttribute.Approved || quote.Status == CRQuoteStatusAttribute.Sent);
}
With this you may also remove reference to enable/disable in your initialize method as such it would be as follows.
public override void Initialize()
{
base.Initialize();
Base.actionsFolder.AddMenuAction(PrintQuoteSummary);
Base.Actions.Move("PrintQuote", "printQuoteSummary");
}

Hide field POOrder Entry

I was asked to make what I thought would be a very simple customization, hide the Promised On field on the PO Order Entry page. I opened the PO301000 screen in the customization editor, highlighted Promised On, clicked Attributes and clicked Override on Screen Level. I changed the resulting code on POOrderEntry to:
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
#region Event Handlers
[PXDBDate()]
[PXDefault(typeof(POOrder.orderDate), PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Promised On", Visibility = PXUIVisibility.Visible, Visible = false)]
protected virtual void POOrder_ExpectedDate_CacheAttached(PXCache cache)
{
}
#endregion
}
}
To my surprise, it did not work, the Promised On field is still visible and I do not know why. The version is 18.100.0062.
It looks like there is a RowSelected event in POOrderEntry that sets the visibility based on if it is a blanket PO. Since this is later in the chain of events it overrides the CacheAttached event.
You can get what you want by adding your own RowSelected event. Here's an example.
protected void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
PXUIFieldAttribute.SetVisible<POOrder.expectedDate>(cache, null, false);
}
GeorgeM use the code below. The trick is to call baseMethod before making changes to the visible state of the field.
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension<POOrderEntry>
{
[PXOverride]
protected virtual void POOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseMethod)
{
baseMethod(cache, e);
PXUIFieldAttribute.SetVisible<POOrder.expectedDate>(cache, null, false);
}
}
}

How to create Right Click and Middle Click event on custom hyperlink button?

I am creating my Custom hyperlink button deriving from Silverlight HyperlinkButton I want to create Right Click and Middle click event on it. Can some help me please.
Thanks,
Gobind
I would add a couple of events (like MiddleClick and RightClick), then handle the MouseUp (or MouseDown, if you want to intercept on the down), then fire one of the two events depending on the details of the MouseUp event. For example:
public MyControl()
{
InitializeComponent();
MouseUp += OnMouseUp;
}
void OnMouseUp(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Middle)
{
OnMiddleClick(e);
e.Handled = true;
return;
}
if (e.ChangedButton == MouseButton.Right)
{
OnRightClick(e);
e.Handled = true;
return;
}
}
public event MouseButtonEventHandler RightClick;
protected virtual void OnRightClick(MouseButtonEventArgs e)
{
var handler = RightClick;
if (handler != null) handler(this, e);
}
public event MouseButtonEventHandler MiddleClick;
protected virtual void OnMiddleClick(MouseButtonEventArgs e)
{
var handler = MiddleClick;
if (handler != null) handler(this, e);
}

Resources