Rename EmplId

How do I rename a EmplId in Dynamics AX 2009, there is renamePrimaryKey method on EmplTable but on the Record information the rename button is not available. I can rename other main table primary keys but not EmplId.

Thanks!

Hi,

First of all why do you want to rename EmplId? Have you considered just renaming the label?

The company have changed their employee number format and numbers, and want to change all the existing records.

Hi,

If you hav own EDT with label,then no need to give label for your field,it will pick from EDT label,Otherwise jst give the label in the properties of your field

HI

If u want to change the Empl Id in EmplTbl you can change the EDT EmplId with the differnt Label Name . But it may effect all the Tables where EmplId is using . So first you check with Functional People it should be reflected in the Current table are all the tables. According the req u can change the EDT at the base level only.

If u want the reflection the 1 tbl u can change the label name .

Thanks for all the feedback; I think I my question am not very clear.

I don’t want to rename the label I want to change the data, but employee (EDT emplId) cannot be change.

The companies had changed their employee number format and numbers, and want to change all the existing records.

Example:

To change an Item I:

  1. Click >

  2. Right-click the field.

  3. Select Record info, and then click .

  4. Type the new item number.

  5. Click

But the same functionality is not available on employee.

Hi,

You can try updating the employee Ids using a job. Here is a sample -

static void renameEmployeeId(Args _args)
{
EmplTable emplTable;
;

ttsbegin;
select firstOnly forUpdate EmplTable
where EmplTable.EmplId == ‘9999’;

if (EmplTable.RecId != 0)
{
EmplTable.EmplId = ‘8888’; //New employee Id
EmplTable.renamePrimaryKey();
EmplTable.update();
}
ttscommit;
}

Please note that depending on transaction volume, this job might take a while to run.

Also please test this in Test environment thorughly before implementing this in Production

Thanks Harish Mohanbabu,

When I ran your job on three different environments, it ran without any errors but the data don’t change.

I have refreshed the data and also restarted the service; and checked the SQL database (EmplTable).

I don’t think it is cache.

Hi,

Let us start with the obvious. I assume you are a developer.

  1. did you change the emplId in the select loop?

  2. also can you see whether the job selects a record?

  1. yes, I have changed the emplId in the select loop.

2)Yes, I changed the job to report if the employee not found

if I use a employee that do not exist I get a message.

static void renameEmployeeId(Args _args)
{
EmplTable emplTable;
;

ttsbegin;
select firstOnly forUpdate EmplTable
where EmplTable.EmplId == ‘Old’;

if (EmplTable.RecId != 0)
{
EmplTable.EmplId = ‘New’; //New employee Id
EmplTable.renamePrimaryKey();
EmplTable.update();
}
else
{
Info(‘Employee not found’);
}
ttscommit;
}

Hi,

Did you have any success renaming employee Ids yet?

BTW the job in your post will only select one employee whose employee Id is ‘old’.

If you want to update employee Ids of all employees, you have to do the following -

  1. Create CSV file with 2 columns - old employee Id and new employee Id

  2. Extend the job mentioned in my post. First - the job should read the CSV file. Second - the job should look for old employee Ids. Third - once a match is found, it should update the old employee Id with the new employee Id.

  3. All along the job should keep a count of number of employees read and number of employees updated. If I understand your requirement correctly, I would imagine this count should reconcile.

It should be an easy job for a developer.

Hi,

The above you mentioned renaming option is only available for primary key.write the job for updation of records.