Templates

Hi,

How can i delete/edit templates in Microsoft Dynamics AX 2009?

I created new templates for customers but i am not able to delete them or edit them. Now i have a list of 10 templates that are messed up and i dont need them. Is there a way to remove templates from a list given when i create new customer?

Thanks in advance!! [*-)]

forget about the old templates and create a new one using the template wizard

Are they company or user templates? It makes a difference to the answer. You can however easily delete both.

  1. Company: Basic - Setup - Record templates - Delete them from in here

  2. User: Administration - Common Forms - Users - User Options - Usage Data - Record Templates tab - Delete them from in here

When I try to delete Company record templates (the individual templates, not all templates for one table), it acts like it is deleted and then when I open it back up, they are still there. I see that the template data is stored as a container in the SysRecordTemplateTable. There is one record for each table (tableID) and all the templates for that table are stored in the data container. I don’t see any code anywhere that would go into the container and remove your template. I don’t think this is supported out of the box. Has anyone written any code to make the delete work properly??

Ok, let me qualify. If, for example, the item that the template was based off of was deleted, then the template no longer has a record associated with it. In this case, the template will not delete. These are precisely the templates we’re trying to delete. Any ideas?

Here was the solution I implemented:

In the SysRecordTemplate class I changed this code:

if(common.TableId == tablenum(EventRuleData))
{
excludeValidateField.add(fieldId2Ext(fieldnum(EventRuleData,RuleId),1));
}

to this:

switch(common.TableId)
{
case tablenum(EventRuleData):
excludeValidateField.add(fieldid2ext(fieldnum(eventRuleData,RuleId),1));
break;
case tablenum(InventTableModule):
excludeValidateField.add(fieldid2ext(fieldnum(InventTableModule,ItemId),1));
break;
case tablenum(InventItemLocation):
excludeValidateField.add(fieldid2ext(fieldnum(InventItemLocation,ItemId),1));
break;
}

The above code will prevent the issue from happening in the future (now when the item that the template was built on was deleted, it will not corrupt the template). There was still the issue of cleaning up the corrupted templates. Here is the code I used to do that:

// This job will delete the empty templates from the SysRecordTemplateTable
// Just set the string variable ‘toDelete’ to the display name of the template you need deleted
// and run this job

static void DeleteEmptyItemTemplates(Args _args)
{
SysRecordTemplateTable templateTable;
int j,i,d,x;
container template;
str toDelete = “TEST”
;

ttsbegin;
select forupdate data from templateTable where templateTable.table == TableNum(InventTable);
for(j = 1; j <= conlen(templateTable.Data); j++)
{
template = conPeek(templateTable.Data,j);

i = confind(template,toDelete);
if(i)
{
templateTable.Data = conDel(templateTable.Data,j,1);
templateTable.update();
info(strfmt(“Deleted container %1 - %2”,j,toDelete));
break;
}

}

ttscommit;

}

Hi Adam,

Kindly advise which Module I must look in for option 1 above? I have created Vendor and Customer Templates that I need to delete.

Thanks

Jag