I have a row of data (type InventoryItem) that originated from a different Acumatica instance db. I want to simply insert it using the InventoryItemMaint.Item view. I cleared out the originating InventoryID value first since it's an identity column. I tried both nulling it out and setting it to zero. Whatever I set it to, it throws a PXFieldValueProcessingException that the InventoryID can't be found; but of course it's not supposed to be found, it's supposed to be generated when inserted into the db. The code simply does:
graph.Item.Insert(row);
The error message also mentions the DfltSiteID field. Does it maybe fire all field update events when I call view.Insert() and an event handler might unsafely reference InventoryID? Any ideas what I'm missing?
Related
I know the normal way to get all records of an entity is
http://localhost/AcumaticaERP/entity/Default/17.200.001/"entity"
However, when I use this method to return the Contact entity I receive an error.
"exceptionMessage": Optimization cannot be performed.The following fields cause the error:
AddressValidated: View AddressCurrent has BQL delegate
ExceptionType: PX.Api.ContractBased.OptimizedExport.CannotOptimizeException
I have tried adding parameters such as filtering by last modified date this still did not work. I know that you can get a single contact by providing the ID but this is not what I want. I want to return a list.
I've created some code that uses a number of fields (eg: length, width, LbsPerInch) to calculate the order quantity. I've used this:
cache.SetValue<SOLine.orderQty>(e.Row, dQO);
That part work perfectly. After that's updated, I need to have the line update the rest of the line as though the orderQty was updated manually.
I tried using the following, but that must not be correct, as it seems to just completely hand the form when it runs.
Base.Transactions.Update(row);
Base.Transactions.View.RequestRefresh();
Thanks in advance!
When the user modifies a field on screen it raises the FieldUpdated event for that field.
The base graph you are extending can declare handlers for these FieldUpdated events. The issue could be that the OrderQty field events aren't raised and the base graph uses those events to update other fields which values depend on OrderQty.
The SetValue method changes field value without raising field events.
The SetValueExt method changes field value and raises field events.
You can try using SetValueExt instead of SetValue:
cache.SetValueExt<SOLine.orderQty>(e.Row, dQO);
This is usually sufficient. The most stubborn refresh issues can usually be dealt with by calling the RaiseRowUpdated method to raise the row events after the field has been modified.
I am trying to filter the Case classes based on the contract selected. If a wrong Case class is selected for particular contract then I am throwing an exception on Class ID field.
Below is the line of code I have used to throw an exception
throw new PXSetPropertyException<CRCase.caseClassID>("Incorrect Case Class for Contract");
After the exception, the selector shows ID instead CD value. can anyone tell me why?
It would be helpful to have more detail, like the whole function where you added your code.
Depending on where you are throwing that exception, you may be cancelling the event sequence.
The events for trigger in certain order, and the PXSelector attribute uses DAC events to update and subtitute the field value in the UI with the display value.
Try moving your exception to the FieldValidating event method in the graph.
I have a case in my customisation project, were I have a PXSelector that I want it to solely act as a lookup, and would not like the users to input any data via the selector and create new records.
I could not find a way to limit this from the attribute itself, therefore I tried to limit it from the events that the control fires. The idea was that in the FieldUpdating Event I would verify whether the value inserted by the user can be found in the selector's key column, if not I would revert it back to the old value. The problem was that cancelling the event had no effect on the selector and since I did not know what the previous value was, I could not revert it back manually.
It sounds like you are trying to use a filter. You need a PXFilter view which then could be used to display data in a grid for example.
You can search the source for "PXFilter to find good examples. One I found is APVendorBalanceEnq which uses public PXFilter<APHistoryFilter> Filter
PXFilter views are not committed to the database. Typically you would create a new DAC for the filter based on your needs but you can use existing DACs that are bound to tables without the fear of the data making it to the database. With the filter you simply use the field values rather than load records into the view.
This question covncerns my lack of understanding of how to use the core data undo manager and how to restore a NSManagedObject to its state before editing was done.
I am just learning my way around Core Data. I have my NSManagedObject classes set up with their dynamic accessors. I perform a fetch that returns several NSManagedObject entity results. Content from each of these entity results (first name, last name) get put into a table view, and then the user picks one out of the table for detailed view and then editing.
The detail view controller receives a pointer to the selected NSManagedObject entity. As the user edits the fields, the corresponding property value in the NSManagedObject entity is updated. This seemed like the cleanest way to manage these changes.
Now, rather than committing the changes using save, I want to provide a cancel-editing feature that rolls back to what is in the data base for that entity. I really only want to restore the one entity and not perform the entire refetch.
I tried rollback and I tried NSUndoManager (with beginUndoGrouping and endUndoGrouping), and that is not working. I don't think I understand what rollback is really supposed to do.
But in any case, I still want to restore the property values in just that single entity (taking the lazy approach to only fetch what is needed, which is the one entity) so that my detail view controller can refill its view with the correct information. Right now it is using the NSManagedObject entity values, which contain the edited values, which were cancelled.
I suppose I could just start the edit process by creating a copy of the NSManagedObject. If the cancel-editing button is pressed, I could copy it back into the original. (I might even be able to just replace the original with the copy by moving the pointer. But since the pointer has actually been passed through several objects, I'm not sure how to manage the retain number on the copy.)
Does anyone have any other suggestions?
Thanks
Using rollback should accomplish what you want and I'm not sure what it doesn't. It is probably an implementation detail error.
You can find the specific managed object/s that were updated but not yet saved by calling the context's updatedObjects.