Update primary key value

hello , I have some records in entities but when I want create new record using service the bellow error happens :
"Error creating panel {panelId=100207}: record already exists or related record does not exist [23000]\nDuplicate entry ‘100207’ for key ‘PRIMARY’
its because the counter of primary key is not update how can I solve the problem ?

2 Likes

Hi Mahdi, please share the relevant part of your code so we can better understand & assist you.

hi, its just simple create service , but the problem is the primary key counter is not update with the entity data so when I want create new record it says this primary key is exist .

If you’re creating the record using moqui’s create#path.to…EntityName service, I would say make sure you’re not passing any existing PK values in your in-parameters map.

But again, I can’t really tell what’s going on without looking at your code.

Yes, the code is important as Marwan write… if you are not using the entity auto services (ie “create#${entityName}” for the service name) then you need to explicitly call the method on EntityValue or EntityFacade to generate a primary sequenced ID (as in single primary key sequenced ID, different from secondary sequenced ID like for OrderItem.orderItemSeqId and other similar *SeqId fields.

1 Like