0
votes

I'm new to Acumatica custom development and I'm trying to do something that I would assume is very simple. I have a Selector control (DataClass: FSServiceOrder, DataField: BranchLocationID) in the Sales Order header that allows user to set the Branch Location. Below, in an Inventory grid, I merely want to set the Warehouse field in the new row equal to the value of the above-mentioned selector. I can set Warehouse with a hard-coded value, but I have no idea how to reference the selector or get it's value, as it seems to be outside the scope of the passed PXCache object:

protected void FSSODetPart_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{      
  string BranchLocationID = "" // Not sure how to get this value

  var row = (FSSODetPart)e.Row;
  cache.SetValueExt(row, "SiteID", BranchLocationID);
}

I was hoping I could simply reference all UI controls similar to ASP.NET, but that doesn't seem to be the case. Any help is appreciated. Getting a value from the screen seems to be fundamental but I cannot find any help in the documentation. Thanks.

1
This is a simple task and I think the best recommendation is to review the training material for Acumatica. I say this as RowSelected is not a place to update values. Understanding the events and when to use them will save you a lot of headache and improve the quality of the customization. To get the values of the current document you will use the view name Current property. Example: Document.Current for sales order header DACBrendan
Agreed. Please understand that I was under the gun with a brand new system and customization that needed to be "done yesterday." Now that I have solved the issue, I can finally take the time needed to immerse myself in training. Thanks.TJP
I assumed that was the case. Just from my experience learning Acumatica - make note of the events and when best to use them. Good luck with your Acumatica development project.Brendan

1 Answers

2
votes

In Acumatica screen controls are bound to DataViews. DataViews contains DAC records. Common practice is to get the value from the current DAC record in the bound DataView.

Use the current object of the DataView holding FSServiceOrder DAC records:

string BranchLocationID = myDataview.Current.BranchLocationID;

If you don't know the DataView name, on the WebSite hold Ctl+Alt and click on the BranchLocationID UI field. A popup will appear showing the DataView name.

Getting the current object from the DAC collections should work too but it's preferable to use the DataView:

string BranchLocationID = Base.Caches[typeof(FSServiceOrder)].Current.BranchLocationID;

Also make sure you set the CommitChanges attribute to true on BranchLocationID form field in the Aspx file. This ensures that current object will fire events in the back-end when it's value is changed.

     <px:PXSelector ID="edBranchLocationID" runat="server" 
                    DataField="BranchLocationID" CommitChanges="True" />