Conditionally Enable and Loop through SOLines based on Document checkbox
Im trying to loop through each line of my grid from a checkbox (Auto Assemble Kits) in the main document header to enable/disable all rows of my grid with custom int field usrAutoBuildReq (also check if line IsAKit). Again spent half a day on this and strange behaviours at best?...
foreach (SOLine line in Base.Transactions.Select()) { SOLineExt soLineExt = line.GetExtension<SOLineExt>(); //if IsKit then Enable custom field usrAutoBuildReq
}
}
}
Page 1 / 1
protected virtual void _(Events.RowSelected<SOLine> e, PXRowSelected baseHandler) { if (e.Row == null) return;
// Call Base Handler baseHandler?.Invoke(e.Cache, e.Args);
Use the above code. You need RowSelected for SOLine
This code below works quite well. Im using Row Updated in SOOrder so that I can access the DAC extension for the UsrAutoAssembleKits which is in the Document. However the below code is not saving UsrAutoBuildReq to the database? And commit changes are true?
The code I provided for sure will enable/disable the lines as you have described. If you have other issues please post a separate thread.
Please note you will need to implement UI controls using RowSelected. If you use RowUpdated the disable/enable logic will only work if a change is made to the header record (in your case). If a user opens a document and doesn’t make a change to the header then the logic won't be triggered and the field you want to disable will NOT be disabled.
I also suggest reading/watching T Series courses to have a better understanding of the events and which should be used when and how.
Thank you.
Hi
Yes you were correct. Still dont really know why putting the code under RowUpdated it was not saving the data to the database?
Now i have a new issue. Ive successully updated and saved the order with the new value of UsrAutoBuildReq however now Im getting an error message when i try to open the record again? Ive set the DAC field to PXDBDecimal?
protected virtual void _(Events.RowSelected<SOLine> e, PXRowSelected baseHandler) { if (e.Row == null) return; baseHandler?.Invoke(e.Cache, e.Args); var row = (SOLine)e.Row;
You will need different Events for Different purposes. RowSelected will need to be used for UI handling. But, you shouldn’t be modifying data in RowSelected. Also, I am not sure why you loop on SOLine when SOLine itself is already selected as e.Row. Please separate your issues into separate topics for better response.
Im looping through all lines on the SOLine grid to either set a value for UsrAutoBuildReq depending on the checkbox on the main Document and also the IsKit on the row? Im still getting this cast is not valid?
This was the correct solution anyway for this interested..
protected void SOOrder_UsrAutoAssembleKits_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler) {