保存记录后如何获得价值?

问题描述 投票:1回答:1

在“库存项目”屏幕中保存记录后出现问题,它无法按我希望的方式工作。

我想在保存记录后获取并置的值。

我定制了描述字段以连接某些属性的值。

enter image description here

我在RowPersisted事件中具有以下所有代码,我通过BQL查询获取数据的方式:

protected void InventoryItem_RowPersisted(PXCache cache, PXRowPersistedEventArgs e, PXRowPersisted InvokeBaseHandler)
{
        string attr = "";
        string itemClassDesc = "";
        string itemClassCD = "";

        if (InvokeBaseHandler != null)
            InvokeBaseHandler(cache, e);
        var row = (InventoryItem)e.Row;

        PXResultset<InventoryItem> result =
        PXSelectJoin<InventoryItem,
            InnerJoin<CSAnswers,
                On<CSAnswers.refNoteID, Equal<InventoryItem.noteID>>,
            LeftJoin<CSAttributeDetail,
                On<CSAttributeDetail.attributeID, Equal<CSAnswers.attributeID>,
                And<CSAttributeDetail.valueID, Equal<CSAnswers.value>>>,
            InnerJoin<CSAttribute,
                On<CSAttribute.attributeID, Equal<CSAnswers.attributeID>>>>>,
        Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>,
        OrderBy<Asc<CSAnswers.attributeID>>>.Select(this.Base);

        foreach (PXResult<InventoryItem, CSAnswers, CSAttributeDetail, CSAttribute> record in result)
        {
            InventoryItem inventory = (InventoryItem)record;
            CSAnswers answers = (CSAnswers)record;
            CSAttributeDetail detail = (CSAttributeDetail)record;
            CSAttribute attribute = (CSAttribute)record;

            switch (itemClassCD)
            {
                case "0531":
                if (attribute.AttributeID == "A1" || attribute.AttributeID == "A2" || attribute.AttributeID == "A3")
                    {
                        if (attribute.AttributeID == "A2")
                            attr += answers.Value + " ";
                        else
                        if (attribute.ControlType == 1)
                            attr += attribute.Description + " " + answers.Value + " ";
                        else
                            attr += attribute.Description + " " + detail.Description + " ";
                    }
                    break;

                default:

                    break;
            }
        }
        cache.SetValue<InventoryItem.descr>(row, itemClassDesc + " " + attr);
}

效果很好,因为当我按下保存按钮时,描述字段将值连接在一起,但它始终会得到以前的记录。

您能帮我吗?谢谢!

acumatica
1个回答
0
投票

保存项目后,将触发[RowPersisted事件。您需要使用RowPersisting事件或覆盖图形的Persist函数并在调用基本函数之前运行代码。

© www.soinside.com 2019 - 2024. All rights reserved.