Sure, @Bipin,
I am new to LogicApps, and tried performing the ListRecords action, but I am having a bit of difficulty. I have located the GUIDS within Cosmos, but not all are present. My approach is, since I do have the GUIDS within CosmosDB, I can do a query within cosmosdb to see if:
ems_featurecategory value matches what was provided in the CRM, and if there is no match then -> send email notification etc
Here is my code here: any suggestion is helpful
(I do not think I will do the ListRecords in this instance)
{
"definition": {
"$schema": "schema.management.azure.com/.../workflowdefinition.json
"actions": {
"Add_data_from_THFeatures_container_to_EmptyContainer": {
"actions": {
"Compose": {
"inputs": "@body('Push_Items_into_CRM_(free_form_field)')?['ems_featureid']",
"runAfter": {
"Push_Items_into_CRM_(free_form_field)": [
"Succeeded"
]
},
"type": "Compose"
},
"Condition": {
"actions": {
"For_each": {
"actions": {
"Matching_value_returned_from_Cosmosdb": {
"inputs": {
"body": {
"_ems_featurecategory_value": "@{items('For_each')}",
"_ems_productname_value": "@{body('Parse_JSON')?['ProductInCRM']}",
"_ownerid_type": ""
},
"host": {
"connection": {
"name": "@parameters('$connections')['commondataservice']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('emscrmdev11.crm'))}/tables/@{encodeURIComponent(encodeURIComponent('ems_productfeatures'))}/items"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"foreach": "@body('Query_CosmosDB_for_feature_category_lookup_items')?['Documents']",
"runAfter": {},
"type": "Foreach"
}
},
"else": {
"actions": {
"Send_email_with_options": {
"inputs": {
"body": {
"Message": {
"Importance": "High",
"Subject": "Feature Category input needed (test message)",
"To": "test@email.com "
},
"NotificationUrl": "@{listCallbackUrl()}"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"path": "/mailwithoptions/$subscriptions"
},
"runAfter": {},
"type": "ApiConnectionWebhook"
}
}
},
"expression": {
"and": [
{
"equals": [
"@body('Query_CosmosDB_for_feature_category_lookup_items')",
"@body('Query_CosmosDB_for_feature_category_lookup_items')?['Documents']"
]
}
]
},
"runAfter": {
"Query_CosmosDB_for_feature_category_lookup_items": [
"Succeeded"
]
},
"type": "If"
},
"Parse_JSON": {
"inputs": {
"content": "@items('Add_data_from_THFeatures_container_to_EmptyContainer')",
"schema": {
"properties": {
"Blocking": {
"type": "string"
},
"CRMLink": {},
"CXPContact": {
"type": "string"
},
"CreatedBy": {},
"DomainOwnerPriority": {},
"FeatureCategory": {
"type": "string"
},
"FeatureCreatedOnDate": {},
"FeatureId": {
"type": "string"
},
"FeaturePM": {
"type": "string"
},
"FeatureTitle": {
"type": "string"
},
"FeedbackDescription": {
"type": "string"
},
"FeedbackName": {
"type": "string"
},
"FeedbackSource": {
"type": "string"
},
"FeedbackSourceLink": {
"type": "string"
},
"FeedbackSubmittedBy": {
"type": "string"
},
"FeedbackType": {
"type": "string"
},
"Feedbacks": {
"type": "array"
},
"GPM": {},
"Keywords": {
"type": "string"
},
"LeadFeaturePM": {
"type": "string"
},
"ModifiedOnDate": {},
"OrganizationId": {},
"OrganizationName": {},
"OrganizationType": {},
"OwnerInCRM": {
"type": "string"
},
"PGADOLink": {
"type": "string"
},
"PM": {},
"Priority": {
"type": "string"
},
"ProductInCRM": {},
"ReleaseTiming": {
"type": "string"
},
"ReviewStatus": {
"type": "string"
},
"Status": {
"type": "string"
},
"Link": {},
"Title": {},
"VoteRefreshDate": {},
"VotesOnUserVoice": {},
"id": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"Push_Items_into_CRM_(free_form_field)": {
"inputs": {
"body": {
"_ems_productname_value": "@{body('Parse_JSON')?['ProductInCRM']}",
"ems_featurdescription": "@body('Parse_JSON')?['FeedbackDescription']",
"ems_featurename": "@body('Parse_JSON')?['FeatureTitle']",
"ems_keywords": "@body('Parse_JSON')?['Keywords']"
},
"host": {
"connection": {
"name": "@parameters('$connections')['commondataservice']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('emscrmdev11.crm'))}/tables/@{encodeURIComponent(encodeURIComponent('ems_productfeatures'))}/items"
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Query_CosmosDB_for_feature_category_lookup_items": {
"inputs": {
"body": {
"QueryText": "SELECT c.ems_featurecategoryid\nFROM c\nWHERE c.ems_name = f.FeatureCategory"
},
"host": {
"connection": {
"name": "@parameters('$connections')['documentdb']['connectionId']"
}
},
"method": "post",
"path": "/v2/dbs/@{encodeURIComponent('uvoc')}/colls/@{encodeURIComponent('THFeature')}/query"
},
"runAfter": {
"Send_items_back_to_CosmosDB,_replacing_its_ID_with_CRM_ID": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Send_items_back_to_CosmosDB,_replacing_its_ID_with_CRM_ID": {
"inputs": {
"body": {
"CRMLink": "test",
"CreatedBy": "@{body('Push_Items_into_CRM_(free_form_field)')?['_createdby_value']}",
"DomainOwnerPriority": "test",
"FeatureCategory": "@{body('Push_Items_into_CRM_(free_form_field)')?['_ems_featurecategory_value']}",
"FeatureCreatedOnDate": "@{body('Push_Items_into_CRM_(free_form_field)')?['createdon']}",
"FeatureDescription": "@{body('Push_Items_into_CRM_(free_form_field)')?['ems_featurdescription']}",
"GPM": "@{body('Push_Items_into_CRM_(free_form_field)')?['_ems_leadpmforfeature_value']}",
"ModifiedOnDate": "@body('Push_Items_into_CRM_(free_form_field)')?['modifiedon']",
"OwnerInCRM": "@{body('Parse_JSON')?['OwnerInCRM']}",
"ProductInCRM": "@{body('Push_Items_into_CRM_(free_form_field)')['_ems_productname_value']}",
"ReleaseTiming": "@{body('Push_Items_into_CRM_(free_form_field)')?['_ems_releasetimeline_value']}",
"Status": "@{body('Push_Items_into_CRM_(free_form_field)')?['ems_featurestatus']}",
"id": "@{body('Push_Items_into_CRM_(free_form_field)')?['ems_featureid']}"
},
"headers": {
"x-ms-documentdb-raw-partitionkey": "\"@{body('Parse_JSON')?['OwnerInCRM']}\""
},
"host": {
"connection": {
"name": "@parameters('$connections')['documentdb']['connectionId']"
}
},
"method": "post",
"path": "/dbs/@{encodeURIComponent('test')}/colls/@{encodeURIComponent('THEmptyContainer2')}/docs"
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"foreach": "@body('Query_THFeature_container_for_specific_results')?['value']",
"runAfter": {
"Query_THFeature_container_for_specific_results": [
"Succeeded"
]
},
"type": "Foreach"
},
"Query_THFeature_container_for_specific_results": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['documentdb']['connectionId']"
}
},
"method": "get",
"path": "/v3/dbs/@{encodeURIComponent('test')}/colls/@{encodeURIComponent('THFeature')}/query",
"queries": {
"maxItemCount": 1,
"queryText": "SELECT * FROM c WHERE length(c.id)>15"
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"commondataservice": {
"connectionId": "/subscriptions/11/resourceGroups/test/providers/Microsoft.Web/connections/commondataservice",
"connectionName": "commondataservice",
"id": "/subscriptions/11/providers/Microsoft.Web/locations/westus2/managedApis/commondataservice"
},
"documentdb": {
"connectionId": "/subscriptions/11/resourceGroups/test/providers/Microsoft.Web/connections/documentdb",
"connectionName": "documentdb",
"id": "/subscriptions/11/providers/Microsoft.Web/locations/westus2/managedApis/documentdb"
},
"office365": {
"connectionId": "/subscriptions/11/resourceGroups/test/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/11/providers/Microsoft.Web/locations/westus2/managedApis/office365"
}
}
}
}
}