REST message in a specific language
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 01:27 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 02:34 AM - edited 07-11-2023 02:35 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 04:19 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 04:35 AM
What are you writing in your background script???
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 04:45 AM
Just wrote the exact same thing as you did