2017-01-10 26 views
0

我在Contracts上創建了一個自定義Action,用於更新描述以及屬性。Base.Actions.PressSave()不適用於具有批量操作的屬性

它做的很好,當做一個單一的條目,並按動作按鈕,但在大量行動只有描述更新和保存的屬性不是。

在批量操作期間,如何使屬性值保存正確,我需要做些什麼?

 public PXSelect<CSAnswers, 
       Where<CSAnswers.refNoteID, Equal<Current<Contract.noteID>>>> CSAttr; 

     protected IEnumerable testAction(PXAdapter adapter) 
     { 
      //get the activation parameters 
      var a = CSAttr.Select(); 
      Contract mycontract = Base.CurrentContract.Select(); 
      foreach (CSAnswers item in a.ToList()) 
      {      
       if (item.AttributeID == "ACTA") 
       { 
        item.Value = "Won't Update1"; 
        CSAttr.Update(item); //shouldn't this update? 
       } 
       else if (item.AttributeID == "ACTB") //desired mode set by user 
       { 
        item.Value = "Won't Update2"; 
        CSAttr.Update(item); //shouldn't this update? 
       } 
      } 
      mycontract.Description = "This Works Fine"; 
      Base.CurrentContract.Update(mycontract); 
      Base.Actions.PressSave(); 

      return adapter.Get(); 
     } 
+0

@AcumaticGuy,你能分享一下你的羣衆行動嗎? – RuslanDev

+0

使用表的通用查詢生成批量操作PX.Objects.CS.Answers在noteId = refNoteID上左加入PX.Objects.CT.Contract。入口點是財務\應收帳款\工作區\管理\客戶合同。然後啓用「在記錄上啓用批量操作」。在批量操作選項卡上,我添加了我的操作「testAction」。該行爲正常工作並更新單個客戶合同的屬性。我的問題是有什麼不同,我需要做更新屬性與說明字段? – AcumaticaGuy

+0

我建議改變你的代碼是這樣的:foreach(CSAttr.Select(this)中的CSAnswers項) –

回答

0

不需要聲明自定義CSAttr數據視圖:ContractMaint已經包含Answers數據視圖以使用Attributes。

如下實施TestAction,成功地更新兩臺合同說明和屬性值在啓動時從GI設置爲入口點列表中的全新6.00.1596 Acumatica ERP實例:

public class ContractMaintExt : PXGraphExtension<ContractMaint> 
{ 
    public override void Initialize() 
    { 
     TestAction.IsMass = true; 
    } 

    public PXAction<Contract> TestAction; 
    [PXButton] 
    [PXUIField(DisplayName = "Test Action")] 
    public void testAction() 
    { 
     Contract mycontract = Base.CurrentContract.Select(); 
     foreach (CSAnswers attr in Base.Answers.Select()) 
     { 
      if (attr.AttributeID == "CONFIGURAB") 
      { 
       attr.Value = "Updated"; 
       Base.Answers.Update(attr); //shouldn't this update? 
      } 
     } 
     mycontract.Description = "This Works Fine"; 
     Base.Contracts.Update(mycontract); 
     Base.Actions.PressSave(); 
    } 
} 

enter image description here

enter image description here

+0

很好用 - 謝謝。 – AcumaticaGuy