Legacy Dev Forum Posts

 View Only

Sign Up

Help with TranslationMapDefaults when oOnqueue = 0 for idle agents

  • 1.  Help with TranslationMapDefaults when oOnqueue = 0 for idle agents

    Posted 06-05-2025 18:41

    VaunMcCarthy | 2020-06-30 00:29:57 UTC | #1

    As attached, this Data action should retrieve the onqueue agents and filter based on IDLE. This works fine if there is at least 1 agent on queue but it breaks when there's no agents at all on queue.

    I'm also trying to get it to it displays 0 instead of null/blank when there are agents on-queue but none are IDLE.Get-Number-of-Idle-Agents-in-a-Queue-Copy.json|attachment (1.9 KB)


    Jerome.Saint-Marc | 2020-06-30 08:32:01 UTC | #2

    Hello,

    Something like the following, for the Response Configuration, should work:

    { "translationMap": { "idleagentsarray": "$.results[0].data[?(@.qualifier == 'IDLE')].stats.count" }, "translationMapDefaults": { "idleagentsarray": "[]" }, "successTemplate": "{\"idleagents\": \"${successTemplateUtils.firstFromArray(\"${idleagents_array}\",\"0\")}\" }" }

    I have renamed idleagents into idleagents_array in translationMap and translationMapDefaults just to show that this attribute name doesn't need to match what is in the Output Contract. What matters is that the Output Contract parameters appear in the sucessTemplate structure.

    The default idleagentsarray variable is set to an empty array (used when no agents are on queue - no results[0]).

    The firstFromArray method uses a default value ("0") to send back when the array is empty (which happens when no agents are on queue, using default value - and which happens when no agents are in IDLE state, as translationMap then returns an empty array).

    Regards,


    VaunMcCarthy | 2020-06-30 22:23:33 UTC | #3

    Thanks Jerome, that's helped!


    system | 2020-07-31 22:35:09 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: 8143