How to send SQL table data with Web Activity of Azure Data Factory? - azure-data-factory

I have Lookup with query "Select CustomerName, CustomerSales From Customers"
I have Web Activity for Notification purpose and I would like to send list of CustomerNames and Customer Sales. (For example Tesla, 1234000. There are 1-50 rows)
I can successfully send static text with Web Activity, but don't know how to build body for sending all data.
How to send data from table with Web Activity?

I assume you have unselected "firs row" only option inside Lookup activity. If yes, then your lookup data will actually come as array in output json of lookup activity.
So, you should consider writing below expression to get that array.
#activity('Fetch').output.value

Related

Azure data factory - custom mapping for Rest service

So, I am creating a Copy activity that reads from SQL Server table and have to send the data to an API end point with the PATCH request.
API provider specified that the body must be in the form of
"updates":[{"key1":"value1","key2":"value2","key3":"value3" },
{"key1":"value1","key2":"value2","key3":"value3" }, ...
.... {"key1":"value1","key2":"value2","key3":"value3" }]
However, my sql table maps to json this way (without the wrapper 'updates:')
[{"key1":"value1","key2":"value2","key3":"value3" },
{"key1":"value1","key2":"value2","key3":"value3" }, ...
.... {"key1":"value1","key2":"value2","key3":"value3" }]
I use the copy activity with the sink data set being of type Rest ..
How can we modify the mapping, so that schema gets wrapped by "updates" object ?
Using copy data activity, there might not be any possibility to wrap the data (array of objects) to an updates key.
To do this, I have used a lookup activity to get the data, set variable activity to wrap the data with an updates object key and finally, use Web activity with PATCH method and above variable value as body to complete the activity.
The following is the sample data I have taken for my SQL server table.
Use look up activity to select the data from this table using table or query option (I used query option). The debug output would be as follows:
NOTE: If your data is not same as in sample table I have taken, try using the query option so the output would be something as shown below
In the set variable activity, I have used an array variable and used the following dynamic content to wrap the above array of objects with updates key.
#array(json(concat('{"updates":',string(activity('Lookup1').output.value),'}')))
Now in the Web activity, choose all the necessary settings (PATCH method, authorizations, headers, URL, etc.,) and give the body as follows (I used a fake REST api as a demo):
#variables('tp')[0]
Since I am using the Fake REST API, the activity succeeds, but checking the Web activity debug input shows what is the body that is being passed to the Rest API. The following is an image for reference:

Transform FormRecognizer output in Azure Data Factory

I want to Extract tables in PDF file and insert that data into output sink ( CSV \ Azure SQL etc )
I have tried below things
Analyze custom pdf document using Form Recognizer General document as I just want to scrape Tables
Call "Get Analyze Result" REST API from ADF to get Table Array
Now I want to loop through every Table and Cells and insert data into Azure SQL table
How do I achieve this effectively ?
One way I see is , use JSON parsing along with Looping mechanism in ADF to transform Form Recognizer output row by row
Note : I have checked this post already
Extract PDF table data using Azure Form Recognizer
You should be able to achieve this using the cognitive services API with the external call transformation: https://youtu.be/r22nthp-f4g?t=400

Using Logic Apps, how can I input a formatted Table of results from an SQL Stored Procedure into SendGrid Email

Once a day, I need to run an SQL Stored Procedure, which collects a list of results. I then need to input the results, as a nice user friendly table, into an e-mail (SendGrid).
So far, I have setup all connections and got the Logic App to work but the e-mail it generates displays the results like this:
{"Table1":[{"CaseID":"1000001","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000002","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000003","DateOfUdate":"2020-06-09T11:34:57.483"},{"CaseID":"1000004","DateOfUdate":"2020-06-09T11:34:57.483"}]}
How can I get this to be displayed as a proper table?
Case ID DateofUpdate
1000001 2020-06-09T11:34:57.483
1000002 2020-06-09T11:34:57.483
1000003 2020-06-09T11:34:57.483
1000004 2020-06-09T11:34:57.483
Below are images of my Logic App - please let me know if I need to provide more information.
For this requirement, please refer to the steps I provided below:
1. I initialize a variable named "resultSetVar" and store the json data same to yours', use this variable to simulate your "ResultSets" data.
2. Then use "Parse JSON" action to parse the json data.
3. After that, use "Create HTML table" action to create the html with the json array "Table1" from the "Parse JSON" action.
4. At last, put the "Output" from "Create HTML table" action into the "Email body" box.
5. Running the logic app, I received the email shown as below
Hope it helps~

Get Outreach Activity data from ORN via SOAP calls

I use Oracle RightNow via SOAP API.
Using QueryCSV option, I can get a lot of information (E.g.: about an incident SELECT * FROM Incident WHERE ...), but I don't know how to get information about Outreach Activity.
I saw on the RightNow forum that I could get this kind of information from ma_trans table, but I don't know how to select data from this table.
Outreach Activity tab that should show data from the ma_trans table
I tried different approaches, but I always get responses like this:
Request:
SELECT * FROM ma_trans
Response:
...
<n0:RequestErrorFault xmlns:n0="urn:faults.ws.rightnow.com/v1_3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<n0:exceptionCode>INVALID_REQUEST</n0:exceptionCode>
<n0:exceptionMessage>no such table: ma_trans</n0:exceptionMessage>
</n0:RequestErrorFault>
...
or
Request:
SELECT Contact.ma_trans FROM Contact
Response:
...
<n0:RequestErrorFault xmlns:n0="urn:faults.ws.rightnow.com/v1_3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<n0:exceptionCode>INVALID_REQUEST</n0:exceptionCode>
<n0:exceptionMessage>Non-existent column: 'ma_trans'</n0:exceptionMessage>
</n0:RequestErrorFault>
...
How can I get information about Outreach Activity and how can I get data from this ma_trans table?
The ma_trans table is not exposed through the Connect Object Model or ROQL. transactions is exposed through ROQL, as well as some of the other "managed tables", which you can view in any of the documentation for services that expose connect APIs (i.e. the PHP, SOAP, REST, etc. APIs).
You could get this data by creating a report to query for the data that you need, and then use the runAnalyticsReport method to get data from the report. But, since ma_trans can contain a lot of data, be sure that your report is filtered properly as to not extend beyond run time or data threshold limits.

SSRS - Data Driven Subscription -

What I'm trying to do:
I have a report already created that looks for something existing in one database and not in another. 99% of the time the report comes up empty. We do not need to know when there are no results to show. I only want to know when the query returns a result.
What I've done so far:
I have a the Data Source created and a table (view) created to where I can query for Subscriber information.
What I hope can be answered:
Is it all possible to have this report run and email my selected Subscribers only when there is data in the output?
I see you've already looked into Data-Driven subscriptions. You should be able to write your query in the data-driven subscription to test if the report should return results, and if not, send it to a dummy address, and only send it to your subscriber list if there will be data in it.
If you put the dummy address in your table with an IsDummy flag column, you could do something like this:
SELECT [EmailTo]
FROM SubscriptionTable
WHERE IsDummy=0
AND (SELECT COUNT(*) FROM SomeTable)>0 --report should have results
UNION ALL
SELECT [EmailTo]
FROM SubscriptionTable
WHERE IsDummy=1
AND (SELECT COUNT(*) FROM SomeTable)=0 --report should not have results
And that's only one way, there are probably lots of other ways that might suit your needs as well or better.