gpt4 book ai didi

acumatica - Acumatica 中的发票和备忘录屏幕电子邮件发票/备忘录操作

转载 作者:行者123 更新时间:2023-12-05 06:56:31 25 4
gpt4 key购买 nike

我们已经创建了一些自定义报告,这些报告将根据详细信息选项卡中的销售订单类型打开。当我们使用操作菜单中的电子邮件发票/备忘录操作时,我们希望基于订单类型发送报告的方式相同。

我们试图覆盖代码,但我们仍然看到默认报告是通过电子邮件发送的。我怎样才能解决这个问题?我的代码如下:

        [PXOverride]
public PXAction<ARInvoice> sendARInvoiceMemo;
[PXUIField(DisplayName = "Send AR Invoice/Memo", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public IEnumerable SendARInvoiceMemo(PXAdapter adapter, String reportID)
{
PXReportRequiredException ex = null;

foreach (ARInvoice doc in adapter.Get<ARInvoice>())
{
var parameters = new Dictionary<string, string>();

ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
if (TranData != null)
{
if (TranData.SOOrderType == "WS" || TranData.SOOrderType == "WO" || TranData.SOOrderType == "TS" || TranData.SOOrderType == "IM")
{
if (reportID == null) reportID = "KR501011";
Dictionary<string, string> mailParams = new Dictionary<string, string>();
if (reportID == "KR501011")
{
mailParams["DocType"] = doc.DocType;
mailParams["RefNbr"] = doc.RefNbr;
if (!ReportNotificationGenerator.Send(reportID, mailParams).Any())
{
throw new PXException(ErrorMessages.MailSendFailed);
}
}
Base.Clear();
Base.Document.Current = Base.Document.Search<ARInvoice.refNbr>(doc.RefNbr, doc.DocType);
}

if (TranData.SOOrderType == "RS" || TranData.SOOrderType == "RO" || TranData.SOOrderType == "PS" || TranData.SOOrderType == "QT")
{
if (reportID == null) reportID = "KR501012";
Dictionary<string, string> mailParams = new Dictionary<string, string>();
if (reportID == "KR501012")
{
mailParams["DocType"] = doc.DocType;
mailParams["RefNbr"] = doc.RefNbr;
if (!ReportNotificationGenerator.Send(reportID, mailParams).Any())
{
throw new PXException(ErrorMessages.MailSendFailed);
}
}
Base.Clear();
Base.Document.Current = Base.Document.Search<ARInvoice.refNbr>(doc.RefNbr, doc.DocType);
}
}
}

if (ex != null) throw ex;

return adapter.Get();
}

最佳答案

注意,没有指定版本,所以我的工作是针对 2020r2 完成的。

SendARInvoiceMemo 不会被“Email Invoice/Memo”操作调用。相反,Notification 是该操作的委托(delegate)。

请注意,通知实际上并不是调用报告 ID,而是依赖于通知 CD 和您的邮件设置来确定要运行的报告。我修改了代码以更改为我创建的名为 INVOICEALT 的新 notificationCD。这已配置为我的备用报告 ID。

    [PXOverride()]
[PXUIField(DisplayName = "Notifications", Visible = false)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
public virtual IEnumerable Notification(PXAdapter adapter,
[PXString]
string notificationCD)
{
foreach (ARInvoice doc in adapter.Get().RowCast<ARInvoice>())
{
Base.Document.Current = doc;

Dictionary<string, string> parameters = new Dictionary<string, string>
{
["DocType"] = doc.DocType,
["RefNbr"] = doc.RefNbr
};

using (var ts = new PXTransactionScope())
{
if (ProjectDefaultAttribute.IsProject(Base, doc.ProjectID) && Base.Activity.IsProjectSourceActive(doc.ProjectID, notificationCD))
{
Base.Activity.SendNotification(PMNotificationSource.Project, notificationCD, doc.BranchID, parameters);
}
else
{
//Base.Activity.SendNotification(ARNotificationSource.Customer, notificationCD, doc.BranchID, parameters); //This is what was there
//Inserted switch based on Sales Order Type >>

ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
switch (TranData.SOOrderType)
{
case "IN":
Base.Activity.SendNotification(ARNotificationSource.Customer, "INVOICEALT", doc.BranchID, parameters);
break;
default:
Base.Activity.SendNotification(ARNotificationSource.Customer, notificationCD, doc.BranchID, parameters);
break;
}
//<< Inserted switch based on Sales Order Type
}
Base.Save.Press();

ts.Complete();
}

yield return doc;
}
}

作为上述方法的替代方案,如果您只是谈论用户运行该操作,您可以隐藏电子邮件发票/备忘录操作并放置一个新操作。

    public PXAction<ARInvoice> sendARInvoiceMemoAlt;
[PXUIField(DisplayName = "Alt Email Invoice/Memo", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public IEnumerable SendARInvoiceMemoAlt(PXAdapter adapter, String reportID)
{
PXReportRequiredException ex = null;

foreach (ARInvoice doc in adapter.Get<ARInvoice>())
{
var parameters = new Dictionary<string, string>();

ARTran TranData = PXSelectReadonly<ARTran, Where<ARTran.tranType, Equal<Required<ARTran.tranType>>,
And<ARTran.refNbr, Equal<Required<ARTran.refNbr>>>>>.Select(Base, doc.DocType, doc.RefNbr);
if (TranData != null)
{
if (TranData.SOOrderType == "SO")// || TranData.SOOrderType == "WS" || TranData.SOOrderType == "WO" || TranData.SOOrderType == "TS" || TranData.SOOrderType == "IM")
{
if (reportID == null) reportID = "AR641000";
Dictionary<string, string> mailParams = new Dictionary<string, string>();
if (reportID == "AR641000")
{
mailParams["DocType"] = doc.DocType;
mailParams["RefNbr"] = doc.RefNbr;
if (!ReportNotificationGenerator.Send(reportID, mailParams).Any())
{
throw new PXException(ErrorMessages.MailSendFailed);
}
}
Base.Clear();
Base.Document.Current = Base.Document.Search<ARInvoice.refNbr>(doc.RefNbr, doc.DocType);
}

if (TranData.SOOrderType == "IN")// || TranData.SOOrderType == "RS" || TranData.SOOrderType == "RO" || TranData.SOOrderType == "PS" || TranData.SOOrderType == "QT")
{
if (reportID == null) reportID = "AR641001";
Dictionary<string, string> mailParams = new Dictionary<string, string>();
if (reportID == "AR641001")
{
mailParams["DocType"] = doc.DocType;
mailParams["RefNbr"] = doc.RefNbr;
if (!ReportNotificationGenerator.Send(reportID, mailParams).Any())
{
throw new PXException(ErrorMessages.MailSendFailed);
}
}
Base.Clear();
Base.Document.Current = Base.Document.Search<ARInvoice.refNbr>(doc.RefNbr, doc.DocType);
}
}
}

if (ex != null) throw ex;

return adapter.Get();
}

public override void Initialize()
{
base.Initialize();

Base.ActionsMenuItem.AddMenuAction(sendARInvoiceMemoAlt);
}

关于acumatica - Acumatica 中的发票和备忘录屏幕电子邮件发票/备忘录操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65106136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com