This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Array of JSON in MULTI Instance

How to pass array of JOSN in MULTI Instance Step. I wanted to pass  each array in each thread. so that workflow will run in parallel that would help us . currently it was taking too long time  to process .

For example:

I wanted to pass 100 tickets JSON to process in one run but it takes more time .so, trying to use multi-instance step but list i don't how to pass Array of json value. If that is not possible .Kindly let me know how we can achieve running in parallel.

Thanks in advance

  • Suggested Answer

    0

    MultiInstance uses array as input and will send item in the array to each step.

    I am usually using 2 options.

    1. Create list of numbers between 0 and (array.length-1)..

       Example list: 0,1,2,3,4,5,6

    Input to single step would be list1: 0,1,2,3,4,5,6 and jsonArray

    First step in the single operation would be JSONPath (jsonArray, $[${list1}]) this would return single item in JSON array.

    $[0] ...$[1]...$[2]

    2. Option depends if json array has sub arrays...

    So, jsonArray looks like this: [{"name":"value"},{"name":"value2"},{"name":"value3"},{"name":"value4"}]

    I would transform this list into {"name":"value"}|{"name":"value2"}|{"name":"value3"}|{"name":"value4"}, by removing first [ and last ] and than replacing all },{ with }|{

    {"name":"value"}|{"name":"value2"}|{"name":"value3"}|{"name":"value4"}

    this list is than input to multi instance step as list of values, using | as separator

    And each single operation would than get single Json Item as input

  • 0 in reply to 

    Hi , 

    I tried with option 2 but failed in sometime.

    Could you please let me know how to use Option 1 .

    Explain me how to pass JSON array to multi instance.

    Sample Array:

    [{
    "Incident_ReadSCAD": {
    "OpenedByGroup": "GTS_PAR_EUS_35000_L1",
    "PriorityRisk": "2",
    "ServiceRecipient": "X171554",
    "Solution": ["Administrative Closure."],
    "Subcategory": "laptops",
    "Title": "[INC][COMPUTER] CADENAS BLOQUÉ",
    "Type": "incident",
    "accountability": "Client",
    "closurecode": "Warranty expired",
    "typology": "Process error"
    }
    },{
    "Incident_ReadSCAD": {
    "Assignee": "X101457",
    "Assignment": "GTS_PAR_EUS_OSS.VDF",
    "Category": "eus_printing",
    "Characterisation": "disable",
    "CloseTime": "2018-03-13T17:16:39+00:00",
    "Contact": "A119213",
    "CreateTime": "2018-03-09T08:34:42+00:00",
    "Description": ["***********", " *** Note: Please check the attachments tab for complete email including print screens or attachments ***", "Normal 60 DocumentEmail false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 ", " ", " De ", ": DURANCEAU Ana Christine ResgImmFpmExpVdf Envoyé ", ": jeudi 8 mars 2018 16:56 À ", ": SVP13 <svp13socgen.com> Cc ", ": VAUFREY Thierry ResgImmFpmExpDun <Thierry.Vaufreysocgen.com>; GAUTHEY-SUBASI Marine ResgImmFpmExpVdf <marine.gauthey-subasisocgen.com> Objet ", ": SUPPRESSION IMPRIMANTE ", " Bonjour, ", " Merci de venir récupérer l’imprimante LEXMARK MA0219864 sur VDI A00009B et ses composants du bureau A00.011 RDC PERIVAL/ALIZEA. ", " Cordialement, ", " ", " Ana Christine Duranceau Responsable Services - Pôle VDF RESG/IMM/FPM/EXP/VDF Tél. ", " ", " : +33 (0)1 42 14 32 59 Mob. : +33 (0)6 42 61 06 78 mail : Christine.Duranceausocgen.com ", " ", "***********", "***********"],
    "Flag": false,
    "Id": "P8IN-0280172",
    "IncidentEnd": "2018-03-12T14:15:05+00:00",
    "IncidentStart": "2018-03-09T08:34:42+00:00"
    }
    },
    {
    "Incident_ReadSCAD": {
    "Category": "eus_printing"
    }
    },
    {
    "Incident_ReadSCAD": {
    "Category": "eus_printing11"
    }
    },
    {
    "Incident_ReadSCAD": {
    "Category": "eus_printing213"
    }
    }
    ]

    I wanted to pass only "Incident_Read_SCAD" object values.

  • 0 in reply to 

    Full flow:

    First step is Array size is from /Base [1.21.1]/Library/Utility Operations/Containers/JSON/Array Size
    - input is array (Example: [{"item":"value1"},{"item":"value2}]   )

    - output is: count (in this example is 2

    Operation DO Nothing has count as field1 input

    - output is arrayCountList (from: field1). with added scriptlet filter:

    if (scriptletInput !== null) {
        var max = Number(scriptletInput|0);
        var list = [];
        for(var i=0; i<max; i++){
            list.push(i);
        }
      scriptletResult = list.join(',');
    }

    This creates list: 0,1,2,3 where input is 4

    On Multiinstance:

    Flow that is called in multi instance:

    In ExampleLL flow you have two inputs: array itself and index

    On your first step in ExampleLL flow, you add JSON Path operation

    json is array

    jsonPathQuery is $[${index}], which translates to call $[0], $[1] ...

    So result is element of array in that flow as arrayItem.

    My example next step is Convert Object to Flow Variables

    Which creates V.item variable...with value "value1" for $[0] element...

  • 0 in reply to 

    Thank you so much . It worked. How to get separate run id each run in multi-instance.

    for example: We have arraysize  =5; but everything  is running with same run id .

    I wanted to separate run id for each instance

  • 0 in reply to 

    run_id is same for one flow run. Multiinstance doesn't get new run_id, since after multiinstance step, you have at least Resolved step which is same for all... So, only if you trigger new flow in each multi instance...But, question is, do you need to combine results into single flow to send results. If not, you can use "Dynamically Launch flow"

    /Micro Focus Solutions [2.8.6]/Library/Integrations/Micro Focus/Operations Orchestration/10.x/Dynamically Launch Flow