Rename production ID

Hi,

I need to add a feature to rename prod id in Production order form, could anyone give suggestion to do that?

Thanks.

Is it not working in standard?

Yes its working in standard, but we need to do it directly without going into record info.

What do you mean by doing it directly?

  • Refer \Classes\SysRecordInfo\RenamePrimaryKey, and see if you can make something out of it, OR
  • Go ProdTable > Fields > Select the ProdId field, right click > Properties and then Set AllowEdit property as Yes > Compile it, then go to form related to the production order > Go to its Data sources node> Right Click and refresh. Then Try clicking on the Production ID in the form, and you might be able to directly change it.

I need to select Prodid from a dialog box and pass it to renamekey function to rename the Prodid

See the below example code,

void clicked()
{
Dialog dialog;
DialogField dlgProdId;

dialog = new dialog(‘Update Prod id’);

dlgProdId = dialog.addField(identifierStr(ProdId), ‘Prod Id’);

dialog.run();
dialog.wait();

if (dlgProdId .value() && dialog.closedOk())
{
ProdTable.ProdId = dlgProdId.value();
ProdTable.renamePrimaryKey();
ProdTable_ds.reread();
ProdTable_ds.refresh();
}

}

Shall I create a button directly in production order form and add this method in clicked?

Yes.

it showing like this kranthi

I gave typeid is that okay?

I think identifierStr doesn’t exist in AX 2009. Using TypeId should be fine.

Wen i gave prodid in tat dialog box it isn’t showing anything after that…

What does that mean?

Wen i click rename button in form and gave prodid its showing the below error

pastedimage1516191956200v1.png

pastedimage1516191980874v2.png

Does a production order with that id already exists? Use a number that doesn’t exists in the list of production orders.
Also try using this code, so that you won’t end up with selecting an existing production order.
dlgProdId = dialog.addField(TypeId(str), ‘Prod Id’);

Yes Kranthi.

It showing this error

Also if i doesn’t enter any value there in production id field its not allowing me to close the prodtable form

Done like this Kranthi

dlgProdId = dialog.addFieldValue(Types::String,id,“Production Id”);

pastedimage1516195070694v1.png

But its not allowing me to close wen i didn’t gave any id there, wat should i do now?

Can you show your code?