- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:01 PM
Below is the response I get from an action in flow designer
This is of the type array.Object
{
"Translations": [
{
"detected_language": "en",
"text_translations": [
{
"target_language": "es",
"translated_text": "Hola Mundo"
}
]
}
]
}
From this i want to fetch "translate_text" only in business rule. Please let me know how can i achieve this .
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:18 PM
Hello @Nihal Sarawgi1 ,
You need to run your action in BR in order to get result. And then
Refer below script to fetch value of key.
var obj = {
"Translations": [{
"detected_language": "en",
"text_translations": [{
"target_language": "es",
"translated_text": "Hola Mundo"
}]
}]
};
gs.info(obj.Translations[0].text_translations[0].translated_text);
thanks,
Valmik Patil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:24 PM - edited 11-26-2024 10:26 PM
Hello @Nihal Sarawgi1
Please try this:
// Assuming the data is already an Array.Object
var response = {
"Translations": [
{
"detected_language": "en",
"text_translations": [
{
"target_language": "es",
"translated_text": "Hola Mundo"
}
]
}
]
};
// Navigate to the 'translated_text'
var translatedText = response.Translations[0].text_translations[0].translated_text;
// Log or use the extracted value
gs.info('Translated Text: ' + translatedText);
Result:
Hope this helps!
"If you found my answer helpful, please give like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:18 PM
Hello @Nihal Sarawgi1 ,
You need to run your action in BR in order to get result. And then
Refer below script to fetch value of key.
var obj = {
"Translations": [{
"detected_language": "en",
"text_translations": [{
"target_language": "es",
"translated_text": "Hola Mundo"
}]
}]
};
gs.info(obj.Translations[0].text_translations[0].translated_text);
thanks,
Valmik Patil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2024 10:24 PM - edited 11-26-2024 10:26 PM
Hello @Nihal Sarawgi1
Please try this:
// Assuming the data is already an Array.Object
var response = {
"Translations": [
{
"detected_language": "en",
"text_translations": [
{
"target_language": "es",
"translated_text": "Hola Mundo"
}
]
}
]
};
// Navigate to the 'translated_text'
var translatedText = response.Translations[0].text_translations[0].translated_text;
// Log or use the extracted value
gs.info('Translated Text: ' + translatedText);
Result:
Hope this helps!
"If you found my answer helpful, please give like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2025 06:46 AM
I'm a noob in this field but I find it impossible to get the right information from the Array.Object. Doing translated text and want to update short description in an incident.
Like this:
Am I doing it completely wrong here?