odata query in Azure Logic App giving null value - azure

I am trying to access an integer value from CRM Entity using Parse JSON in Logic Apps. It is returning a null value instead of an integer value.
"territoryinteger": "#{items('For_each')?['_vcm_territoryid_value#OData.Community.Display.V1.FormattedValue']}",
Any help is appreciated.
Thanks

If you look at the Runs History (under the Logic App Overview) and drill down to the Get Record or Get List action block, you can see the output of the JSON retrieved and you can visually verify that the query is returning a value.

Related

Python Function to get data from excel which has 1000 Column

I have a very large excel file and it gets crashed every time whenever I try to find some data so now I'm planning to store the file in Azure Blob Storage/other database and trying to write an Azure function in python so that I can fetch the data from Azure Blob/DB.
I have 1000 Columns and need a dynamic query so that end user can put any column out of 1000 columns to get the data from the excel which is stored in Blob/DB.
Could someone please help me to solution for the same. Which DB would be best and which python library I can use.
I will trigger azure function from Azure API management.
Have a look at the Microsoft example docs for quering Azure Cosmos using the python SDK here. Once we know how to hardcode an azure cosmos query with python, we only need to make it dynamic. Meaning we let the
user specify the column name.
One way you could do that is by creating an azure function that performed the database query. You would allow the user to specify the column name in url query parameters.
As an example, imagine we have an Azure function that is hosted at
https://my-function-app.azurewebsites.com/api/httptrigger1
We would let the user specify which column they would like data from using the url query parameters. They could add which column at the end of url. Example ...
https://my-function-app.azurewebsites.com/api/httptrigger1?MyColumn=Column1
An Azure function can read the url query parameters. They are part of the incoming request object. So, you could use them to dynamically build your sql statement ...
var myColumn = req.Query["MyColumn"]; // Get column name from url query params
QUERY = $"SELECT {myColumn} FROM MyTable"; // build dynamic query
This would allow your user to select their own column using the url!
Note: Be sure to sanitize and parametrize those user inputs to protect against sql injection.

Add Parameter Values to Query String of get request in ADF

I have a Copy Data task which is obtaining data from an API
The API is a GET call to a method and requires 2 parameters
_token
Symbols
I have defined these as parameters
What is the syntax that allows me to use the values of my parameters as the values that are in the query string? So in the screenshot above Symbols is hard coded, but I want the value to be the value of the parameters
I need a screen solution rather than code please as I am not comfortable with ADF yet and I dont know how to get to the code/ARM views
Paul
Using a feature called string interpolation where expressions are wrapped in #{ ... }
Click on the Base URL field. Add Parameters. Using Concat expression function,
Example:
#{Concat('https://stackoverflow.com/questions/GetRealTimeRates?',linkedService().Symbols,'=',linkedService()._token)}
Add first parameter:
Add second parameter:
Test connection. If you see any error, it would provide a description as to debug further.

How to put value as DateTime in Azure Table from Logic App

I have a Logic App that should store data in Azure Table. Everything worked fine until I realized that one of my properties that should be stored as DateTime is stored as String.
The problem is that some other application is doing queries periodically on data in the table and it expects to find DateTimes there:
var query = new TableQuery<UserEntity>().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterConditionForDate(
nameof(UserEntity.AccessEndTime),
QueryComparisons.GreaterThanOrEqual,
DateTime.SpecifyKind(queriedDate, DateTimeKind.Utc)),
TableOperators.And,
TableQuery.GenerateFilterConditionForDate(
nameof(UserEntity.AccessEndTime),
QueryComparisons.LessThan,
DateTime.SpecifyKind(queriedDate.AddDays(1), DateTimeKind.Utc))));
Basically, my C# app is looking for users who have their AccessEndTime property value set to some specific day.
Unfortunately, since the Logic App writes the value as a string, my query does not return any data.
Here's a part of my Logic App:
First I create an object with the proper data as JSON and then I use Insert or Replace Entity block, which used Body of that JSON as an entity to be put in the table. As you can see, AccessEndTime has a type: string. I tried using type: datetime, but it just fails with an error (no such type).
I guess I could handle it on the client-side, but then my UserEntity will have to have AccessEndTime as a String and it just doesn't feel right.
What am I missing?
//EDIT
I also found this. I tried to put my data like this:
So, I added explicitly the type of my property. Unfortunately, the result is still the same.
Check out this SO question's response around the same: Cannot query a DateTime column in Table Storage
It looks like you could have used formatDateTime() as per documentation, but this will not work as described below:
According to some test, the value is still in "String" type but not "DateTime" type. This document shows us the method formatDateTime() response a value in string.
So when we insert the value from method formatDateTime(), it will insert a string into the storage table. It seems there is a bug in display of azure portal, it shows the type is "DateTime". But if we open the table storage in "Azure Storage Explorer" but not on Azure portal, we can find the TimeOfCreation of new inserted record is in "String" type.
For this requirement, it's difficult to get a "DateTime" type value in logic app and insert it into table storage. We can just insert a string. But we can edit the type after insert the new record to table storage. We can do it on Azure portal or in "Azure Storage Explorer". If do it on Azure portal, just click "edit" the record and click "Update" button without do anything(because the type already show as "DateTime"). If do it in "Azure Storage Explorer", just change the type from "String" to "DateTime" and click "Update". After that, we can query the records by "TimeOfCreation" >= Last 365 days success.
The bad thing here is, we can just do it manually on each inserted record. We can't solve this problem in logic app or batch update the type(on portal or in explorer). If you want to batch update the type, you can query all of the new inserted records by this api (use $filter to filter timestamp). And then get each record's PartitionKey and RowKey, and loop them. Use this api to update the column TimeOfCreation type.

Azure Logic App - Foreach over sql resultset

I'm using an Execute Sql Query action in logic app.
Returned result is composed of 1..n tables ("selects").
I want to create a csv table and send it over tfs.
The issue I'm having is that the tables are elements of resultset, and not part of an array.
Is there some way to perform ForEach action on the resultset elements (i.e. - 'Table1', 'Table2', etc...)?
Is there some way to perform ForEach action on the resultset elements (i.e. - 'Table1', 'Table2', etc...)?'
According to the mentioned data format, it seems that it is not supported via foreach action in logic app.
If Azure function is acceptable, I recommend that you could use the Azure function to implement it with your customized logic to deal with data.
Foreach on a Resultset will return JSON object of each row.
I couldn't find any option DesignView to extract the value but you can achieve same in CodeView by assigning following code to your variable in CodeView.
In below MEETINGID is my column name.
"#{items('For_each')?['MEETINGID']}"
"imeetingid": "#{items('For_each')?['MEETINGID']}"
In DesignView, you can use Parse JSON after SQL querying step.
Then, you can use for each in order to reach each database record. Because SQL resultset returns as JSON object in the Logic App.

How to update lookup field of CRM entity using Azure Logic App?

I am currently writing an Azure app which is expected to update records in CRM. I am successfully able to update normal fields, but updating of lookup field is not working.
It gives an error saying -
Property lookupfieldid_value cannot be updated to null. The reference
property can only be deleted.
I am supplying the values in the designer, but when I look at the code view it always shows "lookupfieldid" as null, whereas "lookupfieldid_value" contains the value which I have supplied.
Anyone having an idea of how to pass lookup field value to update CRM records using Logic App?

Resources