cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Delete a token from localization table

KN_9954684
14-Alexandrite

Delete a token from localization table

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.

ACCEPTED SOLUTION

Accepted Solutions

@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) 

View solution in original post

3 REPLIES 3

try to delete from Default,

 

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

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

@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) 

Announcements


Top Tags