0

I have a lookup where I am performing a query to get the employee_no

SELECT employee_no FROM HRS.EMPLOYEE_MASTER WHERE SOC_SEC_NO = '@{variables('FE_SoSecNo')}' this might return the data as follows

{
    "firstRow": {
        "EMPLOYEE_NO": "12345"
    },
    "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ],
        "totalBillableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 3
    }
}

Or if there is no data found

{
    "effectiveIntegrationRuntime": "VMSHIntegrationRuntime",
    "billingReference": {
        "activityType": "PipelineActivity",
        "billableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ],
        "totalBillableDuration": [
            {
                "meterType": "SelfhostedIR",
                "duration": 0.016666666666666666,
                "unit": "Hours"
            }
        ]
    },
    "durationInQueue": {
        "integrationRuntimeQueue": 3
    }
}

I am adding a step to read the value as follows but when the json node does not exists, what I am trying to to insert if the node value was not present and update by getting the value

activity('GetEmpBySSN').output.firstRow.employee_no

enter image description here enter image description here

Can I know how to write the logic to read the value

1 Answer 1

1

I created a Boolean variable to check if response of lookup contains firstrow node or not and the expression I am using to check the existence of the attribute is this

@bool(contains(activity('Lookup1').output, 'firstRow'))

My Boolean variable: enter image description here

Set variable: enter image description here

Output:

  • Lookup output doesn't exist firstrow node: enter image description here
  • As firstrow node doesn't exist variable is returning false: enter image description here

You can then use that boolean variable in an If activity, to get value of node if it exists conditionally based on the value of the variable.

Sign up to request clarification or add additional context in comments.

13 Comments

@pratik Lad thanks can we get the actual value when the json is present?
yes, after this use if condition based on the result of node existence if true take set variable inter true condition take another set variable to access node value.
You mean to say like @equals(variables('emp_exists').value,'true')
yes, and under if condition fetch the value of node if exist
Got it my bad I need to call it by @{variables('employee_no')}
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.