Skip to main content
14-Alexandrite
December 4, 2023
Solved

Delete a token from localization table

  • December 4, 2023
  • 1 reply
  • 1518 views

Hi,

 

LocalizationTables["es"].DeleteToken({
name: "1-Fire Defect Code 38#" /* STRING */
});

 

Unable to delete token which is in es table using delete token service

 

KN_9954684_0-1701695738676.png

This token has been create using service AddorupdateToken on es table.

 

Error in script logs :  Error executing service DeleteToken. Message :: Token [[1-Fire Defect Code 38#]] not found 

 

But this token is present in es table but not in Default table.Please help me with this.

Best answer by wcui

@KN_9954684 

when you add a new token to a non-Default localization from Composer, you are required to set the "Default Token Value". This is because tokens added to non-Default localization are expected to also have a Default value. This is explained in ThingWorx Help Center as below.

  • A default localization table is provided in ThingWorx. If a language-specific translation is not provided, the default localization definition for the token is used.
  • When you define a new localization token, you must define it in the default table and provide a default value

wcui_0-1702955258443.png

 

However, it seems service AddorupdateToken DOES NOT follow above rule. It has only 2 parameters: token name, token value. If you run this service with non-Default localization, the new token will not have a Default value, either be visible in Default localization.

LocalizationTables["**"].AddOrUpdateToken({
	name: "xxx" /* STRING */,
	value: "yyy" /* STRING */
});

For such token, you can only delete it with its original localizatoin, not able to delete from Default.

 

LocalizationTables["**"].DeleteToken({name: "xxx" /* STRING */});

 

 

 

Above actions were all tested with ThingWorx 9.4.0.

If you see different actions or you are using a different version of ThingWorx, please share below to us so we can check deeper.

- thingwrox version

- reproducing steps (including service name, parameter value, screenshots, etc) 

1 reply

17-Peridot
December 4, 2023

try to delete from Default,

 

LocalizationTables["Default"].DeleteToken({
	name: "1-Fire Defect Code 38#" /* STRING */
});
14-Alexandrite
December 4, 2023

Actually some of the tokens have token value in that language but not in Default langauage.

 

So those tokens are not existing in Default localization table

wcui16-PearlAnswer
16-Pearl
December 19, 2023

@KN_9954684 

when you add a new token to a non-Default localization from Composer, you are required to set the "Default Token Value". This is because tokens added to non-Default localization are expected to also have a Default value. This is explained in ThingWorx Help Center as below.

  • A default localization table is provided in ThingWorx. If a language-specific translation is not provided, the default localization definition for the token is used.
  • When you define a new localization token, you must define it in the default table and provide a default value

wcui_0-1702955258443.png

 

However, it seems service AddorupdateToken DOES NOT follow above rule. It has only 2 parameters: token name, token value. If you run this service with non-Default localization, the new token will not have a Default value, either be visible in Default localization.

LocalizationTables["**"].AddOrUpdateToken({
	name: "xxx" /* STRING */,
	value: "yyy" /* STRING */
});

For such token, you can only delete it with its original localizatoin, not able to delete from Default.

 

LocalizationTables["**"].DeleteToken({name: "xxx" /* STRING */});

 

 

 

Above actions were all tested with ThingWorx 9.4.0.

If you see different actions or you are using a different version of ThingWorx, please share below to us so we can check deeper.

- thingwrox version

- reproducing steps (including service name, parameter value, screenshots, etc)