Generating key on save action

Generating key on save action



Entity: test, attributes: Id, Name, Code (text10). Detailscreen with form to edit Name.

The Code attr. must be updated with Id attr padded with 0s to the left with the format function. Problem is that the Id value is not available yet in the save action if i am not mistaken. How to do this?    

Regards, Harry

create and afterwards update...


The Id is normally a "auto number"  but you can  change that in the Id definition, and it became a field you write as any other . The only problem from that solution is that you must ensure the code you writing in the new records is unique. 

Hope have helped




In my action I save (createorupdate),then assign (the code attr with
FormatText(TestForm.Record.test.Id,10,10,True,"0")  and then use an update (with as source the same recordform) This is not working however (error: [W1IZ6U015].DBO.[OSUSR_810_TEST] with key 0 was not updated). So I must be doing something wrong, any idea what?

Regards Harry


yes, you have to fill in the id.



this will give you an Id back, so next up is the assign, i.e. = CreateOrUpdateFOO.Id

and your format

then the update...