Wednesday, August 30, 2023

Edit Dataverse table record error: It is not possible to change transferred line.

I have a dataverse table that was populated using Dual-Write and a D365 F&O entity.  When attempting to edit a record directly on the dataverse table, I get the following error: 

There was an error in saving this record. Unable to write to Finance and Operations apps due to following error(s): {"Write failed for entity VER_SMAServiceOrderLineEntity with unknown exception - It is not possible to change transferred line.\nvalidateWrite failed on data source 'SMAServiceOrderLine (SMAServiceOrderLine)'"} Please rectify your data and try again. If issue persists after multiple retries, please contact your system administrator.

This error is coming from the 'validateWrite' method on the SMAServiceOrderLine table because the service order is in a 'Posted' status.

 

Thursday, August 10, 2023

D365 F&O - DMF Import 'Field 'Service Order' does not allow editing'

 I came across this error while trying to import data into a copied version of the 'SMAServiceOrderHeaderEntity'.  I posted a question about here and was able to find the following solution.

I have a custom Data Entity for the Service Order Table.  My primary key is my ServiceOrderNumber field.
When I import a file with an existing ServiceOrderNumber it updates the record as expected.
However, if I want it to create a new record I can't use the 'Auto Generate' on my primary key as that would break the 'update'.

So, I decided to follow what had been done in the CustCustomerV3Entity.
I set my 'ServiceOrderNumber' 'Allow Edit' field properties on the Entity and Staging table to 'Yes'.

In looking through all the setup and code for the customer entity, this seems to be it.  However, I still get:








Originally, I thought the second error was tied to the first, however, it was not.
In doing more research, I found that the label from this error was this:
 


 




This label is referenced in 4 classes. Only 1 of which would be used by DMF.  
 
That led me to the NumberSequenceTable and the 'numAllowEdit' method.
That method says that unless one of 3 fields is set to 'Yes', the field using the number sequence is NOT editable:
 


 





Once I set 'To a Higher Number' to yes (Seemed like the safest change for my purposes) the '... does not allow editing.' error went away.
The other error remains.  It looks like it isn't generating a new Service Order Number like it should.  Based on the CustCustomerV3Entity, I did the following in the 'initvalue' method of my data entity:
 


 


This is similar to what I see on the CustCustomerV3Entity and other Data Entities that allow Write operations.
I believe this is supposed to tell the field to use the Number Sequence specified in 'SMAParameters'.

However this did not work.  After some trial and error, I found that I had to remove the 'SERVICEORDERNUMBER' column (In my case XML attribute) from my file completely.  It then would successfully import.

This may cause an issue down the line as my import file could come with that field defined for an update or not defined for a new record creation.  We will see how that works out.