在销售报价屏幕中创建操作时出错 CR304500
Error While Creating Action in Sales Quotes Screen CR304500
我在销售报价屏幕中创建了一个操作来创建我的“预测文档”(自定义屏幕)并将预测文档编号返回到销售报价屏幕的“预测”字段中。虽然下面的代码在 SO、PO 和 ARInvoice 等其他模块中工作得非常好。由于错误显示“在系统中找不到预测文档”,但事实并非如此,我可以在预测文档屏幕中看到相同的文档。以下是我的代码:
#region Create Forecast
public PXAction<CRQuote> createForecast;
[PXUIField(DisplayName = "Create Forecast Doc", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
[PXProcessButton(CommitChanges = true)]
public IEnumerable CreateForecast(PXAdapter adapter)
{
CRQuote currentQuote = this.Base.Quote.Current;
if (currentQuote != null && currentQuote.QuoteNbr != null)
{
CRQuote quoteX = PXSelect<CRQuote, Where<CRQuote.quoteNbr, Equal<Current<CRQuote.quoteNbr>>>>.Select(this.Base, currentQuote.QuoteNbr);
if (quoteX != null)
{
CreateForecastMethod(quoteX);
}
}
return adapter.Get();
}
////PrivateMethod Create Forecast.
public virtual void CreateForecastMethod(CRQuote fHeader)
{
//Base.Actions.PressSave();
bool var_forecastCreated = false;
bool erroroccured = false;
string ErrMsg = "";
ForecastEntry forecastGraphObject = PXGraph.CreateInstance<ForecastEntry>();
ForecastHeader forecastHeaderObject = new ForecastHeader();
QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
var Extension = this.Base.GetExtension<SOOrderEntry_Extension>();
try
{
forecastHeaderObject.RefDocNbr = fHeader.QuoteNbr;
forecastHeaderObject.RefDocTotal = fHeader.CuryProductsAmount;
forecastHeaderObject.DocType = "FORECAST";
forecastHeaderObject.ForecastType = "FORECAST";
forecastHeaderObject = forecastGraphObject.ForecastH.Insert(forecastHeaderObject);
forecastGraphObject.ForecastH.Current = forecastHeaderObject;
forecastGraphObject.Actions.PressSave();
var_forecastCreated = true;
}
catch (Exception e)
{
erroroccured = true;
ErrMsg = e.Message;
}
if (erroroccured)
{
// Acuminator disable once PX1053 ConcatenationPriorLocalization [Justification]
throw new PXException("Cannot create Forecast Document: " + ErrMsg);
}
else
{
if (var_forecastCreated)
{
CRQuote QORD = Base.Quote.Current;
CRQuoteExt xQuoteExt = PXCache<CRQuote>.GetExtension<CRQuoteExt>(QORD);
xQuoteExt.UsrForecastInvoice = forecastHeaderObject.RefNbr;
Base.Quote.Update(QORD); //this line gives the error
Base.Save.Press();
}
}
}
#endregion
Error document 'X' cannot found in the system 经常出现是因为selector属性取不到记录
故障排除的第一步是检查数据库中是否存在该记录。
如果选择器过滤掉目标记录,您将收到此错误。您可以删除选择器属性过滤器(连接和 where 子句)以检查这是否是错误的根本原因。
[PXSelector(typeof(Search2<APRegister.refNbr,
LeftJoin<APInvoice, On<APRegister.docType, Equal<APInvoice.docType>,
And<APRegister.refNbr, Equal<APInvoice.refNbr>>>>,
Where<APRegister.docType, Equal<Optional<APRegister.docType>>,
And<APInvoiceJCExt.isJointPayees, NotEqual<True>,
And<IsSchedulable<APRegister>>>>>)]
要调试选择器过滤器,请使用 Acumatica Request Profiler 获取发送到数据库的最终 SQL 请求。
我在销售报价屏幕中创建了一个操作来创建我的“预测文档”(自定义屏幕)并将预测文档编号返回到销售报价屏幕的“预测”字段中。虽然下面的代码在 SO、PO 和 ARInvoice 等其他模块中工作得非常好。由于错误显示“在系统中找不到预测文档”,但事实并非如此,我可以在预测文档屏幕中看到相同的文档。以下是我的代码:
#region Create Forecast
public PXAction<CRQuote> createForecast;
[PXUIField(DisplayName = "Create Forecast Doc", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
[PXProcessButton(CommitChanges = true)]
public IEnumerable CreateForecast(PXAdapter adapter)
{
CRQuote currentQuote = this.Base.Quote.Current;
if (currentQuote != null && currentQuote.QuoteNbr != null)
{
CRQuote quoteX = PXSelect<CRQuote, Where<CRQuote.quoteNbr, Equal<Current<CRQuote.quoteNbr>>>>.Select(this.Base, currentQuote.QuoteNbr);
if (quoteX != null)
{
CreateForecastMethod(quoteX);
}
}
return adapter.Get();
}
////PrivateMethod Create Forecast.
public virtual void CreateForecastMethod(CRQuote fHeader)
{
//Base.Actions.PressSave();
bool var_forecastCreated = false;
bool erroroccured = false;
string ErrMsg = "";
ForecastEntry forecastGraphObject = PXGraph.CreateInstance<ForecastEntry>();
ForecastHeader forecastHeaderObject = new ForecastHeader();
QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
var Extension = this.Base.GetExtension<SOOrderEntry_Extension>();
try
{
forecastHeaderObject.RefDocNbr = fHeader.QuoteNbr;
forecastHeaderObject.RefDocTotal = fHeader.CuryProductsAmount;
forecastHeaderObject.DocType = "FORECAST";
forecastHeaderObject.ForecastType = "FORECAST";
forecastHeaderObject = forecastGraphObject.ForecastH.Insert(forecastHeaderObject);
forecastGraphObject.ForecastH.Current = forecastHeaderObject;
forecastGraphObject.Actions.PressSave();
var_forecastCreated = true;
}
catch (Exception e)
{
erroroccured = true;
ErrMsg = e.Message;
}
if (erroroccured)
{
// Acuminator disable once PX1053 ConcatenationPriorLocalization [Justification]
throw new PXException("Cannot create Forecast Document: " + ErrMsg);
}
else
{
if (var_forecastCreated)
{
CRQuote QORD = Base.Quote.Current;
CRQuoteExt xQuoteExt = PXCache<CRQuote>.GetExtension<CRQuoteExt>(QORD);
xQuoteExt.UsrForecastInvoice = forecastHeaderObject.RefNbr;
Base.Quote.Update(QORD); //this line gives the error
Base.Save.Press();
}
}
}
#endregion
Error document 'X' cannot found in the system 经常出现是因为selector属性取不到记录
故障排除的第一步是检查数据库中是否存在该记录。
如果选择器过滤掉目标记录,您将收到此错误。您可以删除选择器属性过滤器(连接和 where 子句)以检查这是否是错误的根本原因。
[PXSelector(typeof(Search2<APRegister.refNbr,
LeftJoin<APInvoice, On<APRegister.docType, Equal<APInvoice.docType>,
And<APRegister.refNbr, Equal<APInvoice.refNbr>>>>,
Where<APRegister.docType, Equal<Optional<APRegister.docType>>,
And<APInvoiceJCExt.isJointPayees, NotEqual<True>,
And<IsSchedulable<APRegister>>>>>)]
要调试选择器过滤器,请使用 Acumatica Request Profiler 获取发送到数据库的最终 SQL 请求。