1

As mentioned in the below link, I am triggering Lookup first. It gives me Email Ids and then for each of the email id, I am invoking the POST request.

Iterating Through azure SQL table in Azure Data Factory

I have mentioned @pipeline().parameters.tableList in the items in the settings of the For each. And I after for each I have set an email notification to check the output of @pipeline().parameters.leadList. I am getting it correctly so far so good.

But when i am using @item() it is returning me null.

I am confused why @item() giving me null even though @pipeline().parameters.leadList in child pipeline giving me correct value?

And I followed this approach: https://docs.microsoft.com/en-us/azure/data-factory/tutorial-bulk-copy-portal

Parent pipeline

{
    "name": "LookupToSF",
    "properties": {
        "activities": [
            {
                "name": "LookupToSF",
                "description": "Retrieve the Lead name and email ids from the Lead table of the Salesforce",
                "type": "Lookup",
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false
                },
                "typeProperties": {
                    "source": {
                        "type": "SalesforceSource",
                        "query": "select name, email from lead where email='abcd@xxxx.com'",
                        "readBehavior": "query"
                    },
                    "dataset": {
                        "referenceName": "SalesforceObjectToAddPersonAskNicely",
                        "type": "DatasetReference"
                    },
                    "firstRowOnly": false
                }
            },
            {
                "name": "TriggerForEachLead",
                "type": "ExecutePipeline",
                "dependsOn": [
                    {
                        "activity": "LookupToSF",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "typeProperties": {
                    "pipeline": {
                        "referenceName": "SendSurvey",
                        "type": "PipelineReference"
                    },
                    "waitOnCompletion": true,
                    "parameters": {
                        "leadList": {
                            "value": "@activity('LookupToSF').output.value",
                            "type": "Expression"
                        }
                    }
                }
            }
        ]
    }
}

**

Child pipeline

{
    "name": "SendSurvey",
    "properties": {
        "activities": [
            {
                "name": "ForEachLead",
                "type": "ForEach",
                "typeProperties": {
                    "items": {
                        "value": "@pipeline().parameters.leadList",
                        "type": "Expression"
                    },
                    "isSequential": true,
                    "activities": [
                        {
                            "name": "WebActivityToAddPerson",
                            "type": "WebActivity",
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://xxxx.asknice.ly/api/v1/person/trigger",
                                "method": "POST",
                                "headers": {
                                    "X-apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                },
                                "data": {
                                    "email": "@{item().Email}",
                                    "addperson": "true"
                                }
                            }
                        },
                        {
                            "name": "WebActivityForErrorAddingPerson",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Failed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Failure",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "Failure in adding"
                                }
                            }
                        },
                        {
                            "name": "WebActivityToSendSurvey",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Completed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://xxxxxxxx.asknice.ly/api/v1/person/trigger",
                                "method": "POST",
                                "headers": {
                                    "X-apikey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
                                },
                                "data": "Email=@{item().Email}&triggeremail=true "
                            }
                        },
                        {
                            "name": "WebActivityForErrorSendingSurvey",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToSendSurvey",
                                    "dependencyConditions": [
                                        "Failed"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Failure",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "Failure in adding"
                                }
                            }
                        },
                        {
                            "name": "UserAddingNotification",
                            "type": "WebActivity",
                            "dependsOn": [
                                {
                                    "activity": "WebActivityToAddPerson",
                                    "dependencyConditions": [
                                        "Succeeded"
                                    ]
                                }
                            ],
                            "policy": {
                                "timeout": "7.00:00:00",
                                "retry": 0,
                                "retryIntervalInSeconds": 30,
                                "secureOutput": false
                            },
                            "typeProperties": {
                                "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxx",
                                "method": "POST",
                                "headers": {
                                    "Content-Type": "application/json"
                                },
                                "body": {
                                    "Status": "Success",
                                    "message": "@{activity('WebActivityToAddPerson').output}",
                                    "subject": "User Added/Updated successfully"
                                }
                            }
                        }
                    ]
                }
            },
            {
                "name": "SuccessSurveySentNotification",
                "type": "WebActivity",
                "dependsOn": [
                    {
                        "activity": "ForEachLead",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "policy": {
                    "timeout": "7.00:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30,
                    "secureOutput": false
                },
                "typeProperties": {
                    "url": "https://prod-07.australiaeast.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxx",
                    "method": "POST",
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    "body": {
                        "Status": "Success",
                        "message": "@{item()}",
                        "subject": "Survey sent successfully"
                    }
                }
            }
        ],
        "parameters": {
            "leadList": {
                "type": "Object"
            }
        }
    }
}
4

1 回答 1

0

So I found the answer. The item() was giving me null because the foreach parameter was not parsing correctly hence there was nothing in item().

于 2018-05-10T07:13:37.147 回答