adw | 2023-11-29 07:29:41 UTC | #1
I have a observation query action, and I want to get a total amount for two different results, how do I achive this?
{
"translationMap": {
"queueLengthVoice": "$.results[?(@.group.mediaType==\"voice\")].data[?(@.metric==\"oWaiting\")].stats.count",
"queueLengthCallback": "$.results[?(@.group.mediaType==\"callback\")].data[?(@.metric==\"oWaiting\")].stats.count",
"agentsOnQueueInteracting": "$.results[?(@.group.queueId)].data[?(@.metric==\"oOnQueueUsers\"&&@.qualifier==\"INTERACTING\")].stats.count",
"agentsOnQueueIdle": "$.results[?(@.group.queueId)].data[?(@.metric==\"oOnQueueUsers\"&&@.qualifier==\"IDLE\")].stats.count",
"totalQueue": ??
},
"translationMapDefaults": {},
"successTemplate": "{
\"agentsOnQueueIdle\": ${successTemplateUtils.firstFromArray(\"${agentsOnQueueIdle}\", \"0\")},
\"agentsOnQueueInteracting\": ${successTemplateUtils.firstFromArray(\"${agentsOnQueueInteracting}\", \"0\")},
\"queueLengthVoice\": ${successTemplateUtils.firstFromArray(\"${queueLengthVoice}\", \"0\")},
\"queueLengthCallback\": ${successTemplateUtils.firstFromArray(\"${queueLengthCallback}\", \"0\")},
\"TotalQueue\": ${successTemplateUtils.firstFromArray(\"${totalQueue}\", \"0\")}}"
}
If you look at the translationMap, I want the values for "queueLenghtVoice" and "queueLenghtCallback" to be added together in the value "totalQueue".
Ive tried different ways, but I couldn't figure out using Velocity macros with the math prefix how to achive this. Appreciate all insights you could share, thanks.
Jerome.Saint-Marc | 2023-11-29 14:11:42 UTC | #2
Hello,
This should work. I am using 2 temporary variables (nbVoice, nbCallback) to gather the nb of calls and the nb of callbacks so I can then add them with math.add.
{
"translationMap": {
"queueLengthVoice": "$.results[?(@.group.mediaType==\"voice\")].data[?(@.metric==\"oWaiting\")].stats.count",
"queueLengthCallback": "$.results[?(@.group.mediaType==\"callback\")].data[?(@.metric==\"oWaiting\")].stats.count",
"agentsOnQueueInteracting": "$.results[?(@.group.queueId)].data[?(@.metric==\"oOnQueueUsers\"&&@.qualifier==\"INTERACTING\")].stats.count",
"agentsOnQueueIdle": "$.results[?(@.group.queueId)].data[?(@.metric==\"oOnQueueUsers\"&&@.qualifier==\"IDLE\")].stats.count",
"totalQueue": ??
},
"translationMapDefaults": {},
"successTemplate": "#set ($nbVoice = ${successTemplateUtils.firstFromArray(\"${queueLengthVoice}\", \"0\")})#set ($nbCallback = ${successTemplateUtils.firstFromArray(\"${queueLengthCallback}\", \"0\")}) { \"agentsOnQueueIdle\": ${successTemplateUtils.firstFromArray(\"${agentsOnQueueIdle}\", \"0\")}, \"agentsOnQueueInteracting\": ${successTemplateUtils.firstFromArray(\"${agentsOnQueueInteracting}\", \"0\")}, \"queueLengthVoice\": ${nbVoice}, \"queueLengthCallback\": ${nbCallback}, \"TotalQueue\": $math.add(${nbVoice},${nbCallback})}}"
}
Regards,
adw | 2023-11-29 19:27:04 UTC | #3
Thank you very much, this helped! kind regards!
system | 2023-12-30 19:27:12 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 23401