RenamePrimaryKey method on new table

Hello,

I’ve create a very simple table with one field that has a primary index assigned to that table.

How do I get the button Rename when you go to the record information of that field.

It seems to be something about the table method RenamePrimaryKey, but I cannot find how to create this method on a new table.

When looking at the existing tables that have such a method, I cannot find a generic way to create such a method.

Maybe I’m missing something else, but so far I cannot find anything.

Thanks in advance,

Peter

RenamePrimaryKey” function allows us to rename the primary key of almost any record. It is irreplaceable if a record was saved by mistake or simply needs renaming. The function ensures data consistency, that is, all related records are renamed too. It can be accessed from the Record information form, which can be opened by selecting Record info from the right-click menu on any record.

Rename primary key is the method which you will find in almost all the tables under override method. Basically this method can be useful when you are renaming primary key of the table by writing job in AOT(i.e, using table buffer and calling the method accordingly). Just look at the example:

static void CustomerAccountRename(Args _args)

{

CustTable custTable;

;

select firstonly custTable

where custTable.AccountNum == ‘110110’;

if (custTable.RecId)

{

custTable.AccountNum = ‘C’ + custTable.AccountNum;

custTable.renamePrimaryKey();

}

}

Hi Peter,

Usually as long as there is a primary index, this functionality should be enabled automatically. xRecord class which has this method is a kernel class.

Hope this object is compiled and synchronized without any errors. Is there a foreign key relationship setup?

Hi Harish,

Thanks for you reply.

Yes, there is a PrimaryIndex set in the properties of the table.

Yes, there is a foreign key relationship with a related table (set up from the related table under the node ‘relations’, so not on the table itself)

Yes, it did compile and synchronize without errors.

Could I be forgetting something?