getClassdisplayvalue

lalkrishnam
Kilo Contributor

We are using getClassDisplayValue in a integration to get the table name, it works fine. But In some cases the script include where we process the REST transaction is running into error. We observed that this is happening when the user preferred language other than EN. I feel it is because of getClassDisplayValue.

 

Can anyone recommend some best practice to prevent this issue.

1 ACCEPTED SOLUTION

@lalkrishnam If you are using a separate BR for every table you can use pass the table name directly, instead of getting it dynamically.

Thanks,
Anvesh

View solution in original post

5 REPLIES 5

Bert_c1
Kilo Patron

Hi,

 

Do you have sys_documentation records for your languages and table name with element blank? I have those in my instance.

Screenshot 2023-12-10 120619.png

And from:

 

API-getClassDisplayValue

 

A test of the example there in scripts background shows:

 

 

 

// Display the incident table label
var now_GR = new GlideRecord("incident");
var value = now_GR.getClassDisplayValue();
gs.info("The table label is " + value + ".");

 

 

shows:

 

 

*** Script: The table label is FrenchForIncident.

 

 

when I set my language to French.

 

Activate the corresponding I18: [Language] Translation plugin and test.

Thanks Bert for your response. It is helpful.

AnveshKumar M
Tera Sage
Tera Sage

Hi @lalkrishnam 

For example, If you are using the getClassDisplayValue() return value as a parameter in GlideRecord it may fail the script execution. Why because, getClassDisplayValue fetches the Table label in logged in user preferred language if you are using i18n language plugins. Even though if you are not using i18n, the classDisplayValue is always table label not the name, so it will work for some tables like incident, problem etc where both lable and name are same. Where as for tables like change the lable and name are different.

 

I recommend you to use getRecordClassName() to fetch the table name instead of label.

 

Please mark my answer helpful and accept as a solution if it helped 👍

Thanks,
Anvesh

Thanks Anvesh for your response.

 

I'm using BR to trigger the integration. We have a separate BR for every module to trigger the integration by calling the same Script Include and we should pass the table name.

 

As we have a separate BR for every table, can I hard code the table name or dynamically get the table name using getRecordClassName?

 

Please suggest.