微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在“调查屏幕”中删除记录时出现错误

如何解决在“调查屏幕”中删除记录时出现错误

概念是:当我在调查屏幕上保存特定记录时,“ investigationID”字段应保存在另一个名为“偏差报告”的屏幕中(您可以看到以下图像)

调查屏幕图像

偏差屏幕图像(“ investigationID”字段值存储)

但是在这里,当我尝试删除调查屏幕上的粒子“ investigationID”记录时,我遇到了问题。该值应在偏差屏幕的屏幕上变为空(您可以在上图...>黄色标记为“偏差屏幕”的屏幕上看到)

相关代码

我在RowPersisted事件中编写了代码(保存时,此surveyID字段应保存在偏差屏幕中(您可以在“偏差屏幕图像”中看到......正在保存):

    protected void TSInvestigation_RowPersisted(PXCache cache,PXRowPersistedEventArgs e)
    {
        var row = (TSInvestigation)e.Row;
        if (row == null)
            return;

        if (row.InvestigationCD.Trim() != "<NEW>" /*row.InvestigationCD != null && TSInvestigationView.Cache.GetStatus(row) == PXEntryStatus.Inserted*/)
        {

            DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
            DeviationReportMaintGraph.Clear();

            //TSInvestigation get = this.TSInvestigationView.Current;

            //TSDeviationReport retbatch = DeviationReportMaintGraph.TSDeviationReportView.Insert(new TSDeviationReport());
            //TSDeviationReport retbatch = PXSelect<TSDeviationReport>.Select(DeviationReportMaintGraph);

            if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
            {
                TSDeviationReport tSDeviation = PXSelect<TSDeviationReport,Where<TSDeviationReport.deviationCD,Equal<required<TSDeviationReport.deviationCD>>>>.Select(this,row.DeviationDocID);

                if (tSDeviation != null)
                {
                    tSDeviation.InvestigationID = row.InvestigationCD;
                    DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
                    DeviationReportMaintGraph.Actions.PressSave();

                    //DeviationReportMaintGraph.TSDeviationReportView.Cache.Update(tSDeviation);
                    //DeviationReportMaintGraph.Actions.PressSave();
                }
            }
        }
    }

我在RowDeleted事件中编写了代码(当我在调查屏幕上删除该行时,相关的surveycd字段应在“偏差屏幕图像”中看到的“偏差屏幕”上变为空值)

    protected void TSInvestigation_RowDeleted(PXCache cache,PXRowDeletedEventArgs e)
    {

        var row = (TSInvestigation)e.Row;
        if (row == null)
            return;


        DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
        DeviationReportMaintGraph.Clear();

        //TSInvestigation get = this.TSInvestigationView.Current;

        if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
        {
            TSDeviationReport tSDeviation = PXSelect<TSDeviationReport,row.DeviationDocID);

            if (tSDeviation != null /*|| tSDeviation == null*/)
            {
                tSDeviation.InvestigationID = null;

                DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
                DeviationReportMaintGraph.Actions.PressSave();
            }
        }

    }

但是当我删除记录时,却出现以下错误消息:

在调查屏幕上删除记录时遇到此错误

代码中的错误在哪里?

解决方法

您在InvestigationID字段中设置了错误的值-应该是row.InvestigationID,而不是row.InvestigationCD

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。