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.
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 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?
I am currently attempting to create a new Activity type that has it's own maintenance screen.
The most logical approach I came up with was to create a new subclass based on CRActivity with the PXSubstitute flag to replace the stock value with mine that has the extra class types in it.
This works for displaying my new class on the screen however whenever I click on any of the items I always receive the message:
Error #97: A cache instance cannot be created for the type CRActivity.
For reference, here is how i'm defining my new class
[CRActivityPrimaryGraph]
[Serializable]
[PXSubstitute()]
[PXCacheName(PX.Objects.CR.Messages.ActivityClassInfo)]
[PXEMailSource]
public partial class CustCRActivity : CRActivity
{
.....
}
I took a step back and tried another approach by doing the same process but for CRPMTimeActivity. This causes all of the standard Class types to work but my new type gives the same type due to the CRActivityPrimaryGraph not knowing what my new activity type's nagivation is.
Has anyone ever created a new activity type such as this?
Updated 4/28
Below is a screenshot of what I was attempting to accomplish
I did finally get it to work but not quite the way I was hoping.
The initial error message was apparently build specific. After updating to a newer build that particular error went away.
What I discovered was even though I could Substitute CRActivity, most of the screens themselves were utilizing CRPMTimeActivity which has different attributes associated to it. CRPMTimeActivity is a subclass of CRActivity and the majority of the processes cast the activity to CRActivity.
A subclass of CRPMTimeActivity cannot be cast as CRActivity. Because PXSubsitute relies on the base class, this caused casting issues when attempting to add new activities.
In the end I had to create my own custom CRPMTimeActivity class and the base classes then customize the screens themselves to use my version of the activity builders.
The result is shown in the screen shot
I have defined a custom list template type for SharePoint. I install it using VSeWSS 1.3 and everything seems to behave correctly.
I have added a custom action which will add additional columns (SPFields) to the list. However, every time that code executes it throws and ArgumentException with a 'Value not in the expected range.' error message. This behavior seems to be specific to custom types as suggested in this blog post.
Here is the relevant code (thisList is an instance of my custom list template type created using the browser interace) that tries to add a field to the SPFieldCollection of thisList:
SPFieldType fieldType = Format2SPFieldType(format);
SPField field = new SPField(thisList.Fields, fieldType.ToString(), fieldName);
thisList.Fields.Add(field);
The last statement (thisList.Fields.Add(field)) throws the following exception:
Message "Value does not fall within the expected range."
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName, Boolean bThrowException)
at Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName)
at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op)
at Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op)
at Microsoft.SharePoint.SPFieldCollection.Add(SPField field)
This same code executes just fine if the SPList item is the base list type (built-in custom list).
Are there any fields that need to be set explicitly in the CAML and using the AddFieldAsXml() method directly to make this code work with custom list template types?
Update: I should also mention that the fields are actually created in some instances even though the call throws an exception!
Turns out that this was caused because calling thisList.SchemaXML put the SPList object into a state that I wasn't able to recover from! Getting a new reference to the same SharePoint List, e.g., SPList newList=thisList.ParentWeb.Lists[thisList.ID] solved the issue!
What is the Type of Field you are trying to add? is that an Internal field or a Custom Field type, what does this Function Format2SPFieldType return?
If it is a Inbuilt field can you try adding with the
thisList.Fields.Add("DisplayName", SPFieldType.Integer, false);