SQL Script for this - sql-scripts

Sample Data:
I want the value of RNWD_NO will be the USER REFERENCE OF THE OTHER.
ID.2 RNWD_NO will be USER_REF of ID.1 same to others.

Related

How to make the patch function work in PowerApps?

I am currently working on a powerapps app, and I have multiple pages with forms and different SharePoint lists connected to it. But every code I tried for submitting the data to the SharePoint doesn‘t seem to be working. Does anyone have any ides?
Patch('5S Fragen_1';varFormData1; Form1.Updates; Form3.Updates; Form3_1.Updates; Form3_2.Updates; Form3_3.Updates; Form3_4.Updates; Form3_5.Updates; Form3_6.Updates; Form3_7.Updates;Form3_8.Updates;Form3_9.Updates;Form3_10.Updates;Form3_11.Updates; Form3_12.Updates;Form3_13.Updates;Form3_14.Updates;Form3_15.Updates;Form3_16.Updates;Form3_17.Updates;Form3_18.Updates;Form3_19.Updates;Form3_20.Updates;Form3_21.Updates;Form3_22.Updates)
5S Fragen_1 is the name of my SharePoint List and varFormData1 is the item name
You will probably need to write Patch function in a different way:
Patch('5S Fragen_1';varFormData1; {Column1:textbox1.Text, Column2:Textbox2.Text, Column3Number:Value(Textbox3.Text)})
Alternatively, if you are using Forms, you can simply use SubmitForm(FormName1);SubmitForm(Form2); and so on.
Explanation: One way to write a Patch function is:
Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])
Datasource: SharePoint, SQL, Dataverse, etc
BaseRecord: A "record" Type object in Power Apps.
LookUp(DataSource, ID = Value(Textbox1.Text))
or
{ID:Value(Textbox1.Text)}
or
First(DataSource)
or
Defaults(DataSource) - this creates a brand new record in your datasource
ChangeRecord1: What you want to change in that BaseRecord object
{
Title: Box1.Text, //(or maybe ; instead of ,)
Status: dropdown.Selected.Value
//....
}

Is it possible to apply [Rule Chain] after [Data Converter]?

I am currently working on a POC by using ThingsBoard PE.
Our raw data contains [Asset] [Attributes].
Data flow:
[IoT cloud] --https webhook carry raw data--> [ThingsBoard PE HTTP INTEGRATION] --uplink--> [ThingsBoard PE Data Converter]
My question is: is it possible to apply [Rule Chain] after [ThingsBoard PE Data Converter]? Therefore, the device can auto create relationship with [Asset] by the [Attribute], instead of [AssetName].
Example data after data converter process:
{
"deviceName": "ABC",
"deviceType": "temperature",
"attributes": {
"asset_id": 6 // <-- the id is used in asset attribute
},
"telemetry": {
"temperature": 39.43
}
}
Answering your two, separate questions:
is it possible to apply [Rule Chain] after [ThingsBoard PE Data Converter]?
Yes it is possible. Once your data is successfully integrated and you are receiving it, you can access it using the [Input] Rule Node (the default green one that is always there when you create a Rule) and route it to any other node you need.
Therefore, the device can auto create relationship with [Asset] by the [Attribute], instead of [AssetName].
So, you want the relationship to take your custom attribute and use that as the pattern that identifies the Asset you want to create the relationship from.
The PE edition already has the Create Relation Node. However, seems that as it is one is not able to do what you seek (has no option to specify custom Asset id).
However, two options you got are:
Create a Custom Rule Node that does what you want. For that try checking the Rule Node Development page from Thingsboard. You can use the Create Relation Node as base and work from there. This can be a longer solution than doing...
Enrich your incoming message's metadata, adding your desired attribute. The Create Relation Node allows you to use variables on your message's metadata in your Name and Type patterns, as seen from this screenshot I took from that node:
This allows us a workaround to what you want to do: Add a Script Transformation Node that adds attributes.asset_id to the metadata, for example as metadata.asset_id, so you can then use it as ${asset_id} on your Name and Type patterns.
For example, your Transform() method of such Script Transformation Node should look something like this:
function Transform(msg, metadata, msgType){
//assumming your desired id is msg.attributes.asset_id, add it to the metadata
metadata.asset_id = msg.attributes.asset_id;
//return the message, in your case to the Create Relation Node
return {msg: msg, metadata:metadata, msgType:msgType};
}
Finally, your Rule should be connected like this:
[Input] -> [Script Node] -> [Create Relation Node] -> [...whatever else you like]

Azure Data Factory get data for "For Each"component from query

The situation is as follows: I have a table in my database that recieves about 3 million rows each day. We want to archive this table on a regular base, so that only the 8 most recents weeks are in the table. The rest of the data can be archived tot AZure Data lake.
I allready found out how to do this by one day at a time. But now I want to run this pipeline each week for the first seven days in the table. I assume I should do this with the "For Each" component. It should itterate along the seven distinct dates that are present in the dataset I want to backup. This dataset is copied from the source table to an archive table on forehand.
It's not difficult to get the distinct dates with a SQL query, but how to get the result of this query into an array that is used for the "For Each" component?
The issue is solved thanks to a co-worker.
What we have to do is assign a parameter to the dataset of the sink. Does not matter how you name this and you do not have to assign a value to it. But let's assume this parameter is called "date"
After that you can use this parameter in the filename of the sink (also in dataset) with by using "#dataset().Date".
After that you go back to the copyactivity and in the sink you assign a dataset property to #item().DateSelect. (DateSelect is the field name from the array that is passed to the For Each activity)
See also the answer from Bo Xioa as part of the answer
This way it works perfectly. It's just a shame that this is not well documented
You can use lookup activity to fetch the column content, and the output will be like
{
"count": "2",
"value": [
{
"Id": "1",
"TableName" : "Table1"
},
{
"Id": "2",
"TableName" : "Table2"
}
]
}
Then you can pass the value array to the Foreach activity items field by using the pattern of #activity('MyLookupActivity').output.value
ref doc: Use the Lookup activity result in a subsequent activity
I post this as an answer, because the error does not fit into a comment :D
have seen antoher option to accomplish this. That is by executing a pipeline from another pipeline. And in that way I can define the dates that I should iterate over as a parameter in the second pipeline (learn.microsoft.com/en-us/azure/data-factory/…). But unformtunately this leads to the same rsult as when just using the foreach parameter. Because in the filename of my data lake file I have to use: #{item().columname}. I can see in the monitoring view that the right values are passed in the iteration steps, but I keep getting an error:
{
"errorCode": "2200",
"message": "Failure happened on 'Sink' side. ErrorCode=UserErrorFailedFileOperation,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=The request to 'Unknown' failed and the status code is 'BadRequest', request id is ''. {\"error\":{\"code\":\"BadRequest\",\"message\":\"A potentially dangerous Request.Path value was detected from the client (:). Trace: cf3b4c3f-1681-4073-b225-17e1c07ec76d Time: 2018-08-02T05:16:13.2141897-07:00\"}} ,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.Net.WebException,Message=The remote server returned an error: (400) Bad Request.,Source=System,'",
"failureType": "UserError",
"target": "CopyDancerDatatoADL"
}

Is there any limit for source in typeahead?

I am using JQuery typeahed from RunningCoder. Typeahead works well if I have few records in my source, but does not work if my source has around 500 records.
It is not related to the result count, which can be managed by maxItem parameter. Also, there is no issue in getting the JSON string from the server, as I can print it without any issue.
I know ideally, I should not have them in my page pre-loaded and search it based on the input, but in my case hitting the server for search is not an option and I want to perform the search from the static data I have in my view. Here is my code:
$.typeahead({
input: "#List .typeahead",
minLength: 3,
templateValue: "{{Text}}",
display: ["Text", "Subtext"],
emptyTemplate: 'No results for "{{query}}"',
template: '<span>' +
'<span class="result" id="{{Value}}">{{Text}}</span>' +
'</span>',
source: {
Issuer: {
data: #Html.Raw(Model.EveryThing)
}
}
});
In my code above if Model.Everything has 40-50 records then it works fine, but does not work for around 500 records.
ADDITIONAL INFO:
After figuring out the issue, would like to explain it a bit as this may help someone. By using above code, you can search the list based on two fields i.e. Text and Subtext, but the user will see only Text in the result and then can select from matching options. This will be very useful if you want to perform the search on more than one field but show just one field.
Figured it out after creating sample data on my own, rather than relying on server response. The issue is not with the length of the result, but null entries in the result.
In my data, there are few objects with Subtext as NULL, and that causes the issue, I fixed it by replacing the NULL with an empty string, and this works as expected now.

zapier lookup to iterate through array

We are using zapier to push an invoice from Quickbooks Online (QBO) to ShipStation (SS). Everything is mapped fine except the SKU field (which for some reason QBO doesn't pass). So I created a lookup using a multi-zap and the Formatter Utility to match the description to a table of description/skus I made.
The limitation is that the Formatter Utility will only run once and not iterate through the payload array. Tech support told me this could be done with the code utility, but I'm not sure how to do it. Ideas?
Ok, so the best approach here will be to have 2 different zaps.
Zap A will move have a QBO trigger, go through your filters, and the last step will be a Code action. Zap B will have a "Catch Webhook" trigger and a ShipStation action. Let's go through them.
Zap A has a code step that takes input data. This'll be all of your SKUs separated by commas.
The code step will look something like this:
var skus = inputData.skus.split(',') // now it's an actual array
var otherZapUrl = 'https://zapier.com/catch/12345'
var lookupTable = {
1: 'New York',
2: 'Chicago',
3: 'Los Angeles'
}
skus.map(function(sku){
var payload = {
sku: lookupTable[sku] || 'default',
// other data you want to send along
// name: inputData.name
};
fetch(otherZapUrl, {method: 'POST', body: JSON.stringify(payload)});
})
return [{status: 'ok'}] // this is so the editor doesn't complain
Your second zap will catch the webhook and fill out the SS fields you expect. Hopefully that's straightforward.
As for what you need to do, you'll need to redo your lookup table in javascript (sorry) and replace the otherZapUrl to that of the Zap B endpoint. Also, make sure you specify all of the data you want to pass onto SS in the code's inputData object.
How's that look?

Resources