REST message in a specific language

Frank Silveira
Tera Contributor

Hello Experts, 

 

I have a REST call, triggered by a business rule when the record is updated, where a payload is created based on the record that triggered the rule and then sent to an external service.

Right now my problem is that, since the business rule is triggered by the user, the payload is being created based on the language of that user (fields like "category" that have translated values).

I want those fields to be sent always in the same language. I've tried using the impersonation in the business rule script but when testing it it would always log me out of the instance.

Do you have any suggestions on how can I achieve this?

 

Thank you in advance.

5 REPLIES 5

Sebastian L
Mega Sage

On top of my head, you could maybe use getMessageLang to retrieve the value in the language you prefer, but it will require you to know the key (which usually is the english term if done correctly). 

gs.getMessageLang('message_key', 'language_id');

 

Another way could maybe be to use: 

   var lang = gs.getSession().getLanguage(); // puts the user's current language in a variable
gs.getSession().setLanguage("en");
var translatedField = gr.field.getDisplayValue();
gs.getSession().setLanguage(lang); // sets the langauge back to what it was

 


Best regards,
Sebastian Laursen

gs.getSession().setLanguage() doesn't seem to do anything. Tried on a script background and nothing was done. I also can't find any documentation on this to confirm if I'm using it correctly or not.

What are you writing in your background script???

 

SebastianL_0-1689075335887.png

 


Best regards,
Sebastian Laursen

Just wrote the exact same thing as you did

 

FrankSilveira_0-1689075838765.pngFrankSilveira_1-1689075884174.png