I am creating the logic app when I want to send an email when there are duplicate entries created in my database, and until those are not removed email should be triggered after some interval
As per Logic App, we can create a trigger on SQL when data is inserted or modified as bellow
So I selected the first option then I am adding another action which will run my SQL script to check the logic of duplicate entries
and last I have added another action to send an email.
Now I want my last action of sending email to be executed only when my query comes up with some result
You can use a Condition Control to check whether the given result set is valid if the condition satisfies then you can send the email
See my logic app below.
Here I've added the Execute a Stored Procedure Action. My stored procedure returns resultsets, you can use the logic for checking the duplicate and in the next condition you can check the duplicate result is true (or) false. If it's true you can send email else not to.
Update 1
How to Add condition control
I think you're better off programming the duplicate condition detection into a Stored Procedure rather than a SQL Trigger then using the Logic App change Trigger.
Instead, use a Logic App and Recurrence to call the Stored Procedure that queries for duplicates and returns the necessary meta data.
Trigger + table + change will be less reliable then you expect and much harder to maintain.
Related
I am trying to resolve this error in Power Automate:
Actions in this flow may result in an infinite trigger loop.
Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.
This seems to be a common problem when using this trigger:
When an item is created or modified
where the associated flow contains this action:
Update item
The dynamic is succinctly explained in these videos here and here.
Desired Behaviour
The desired behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
But not when the flow itself updates the item
Actual Behaviour
The actual behaviour is that the flow:
Runs when a list item is created or modified by a user (and updates the item accordingly)
Also runs when the flow itself updates the item (causing an infinite loop)
What I've Tried
Some posts suggest using a Service Account to run the flow and then apply the logic:
If the flow was triggered by a Service Account, terminate the flow
But I do not have access to a service account in this scenario.
The simplest solution seems to be answers like this one and this one.
They suggest creating a column in the SharePoint List to store a 'flag'.
I understand the concept of using flags to indicate:
DO run the flow if SOME_FLAG is false
DO NOT run the flow if SOME_FLAG is true
But I am having trouble when it comes to implementing them properly in this scenario.
Specifically, I have added a Yes/No column to my List called LastModifedByFlow.
The default value is No (i.e. false).
My flow is structured like this:
01) TRIGGER: When an item is created or modified
02) I have added this Trigger Condition
#equals(triggerBody()?['LastModifiedByFlow'],false)
03) This means the flow will run when LastModifiedByFlow is false
04) Create some variables
05) ACTION: Update the item - this includes setting the LastModifedByFlow value to true
Question
The first time the flow runs, it works great:
the item is updated
the item's LastModifedByFlow value is set to true so the flow doesn't run again
But how and where in the flow do I set the LastModifedByFlow value back to false?
So that the flow will run each time a user subsequently modifies the list item?
It is recommended that you set a default value of “Yes” for the Yes/No column first. When the item is created, the flow will be triggered. After the flow is completed, the value of the column "Yes" will become "No". When the item is modified, it is recommended to manually change "No" to "Yes" to trigger the flow. Here is a post for your reference.
I have two fields named as Status and Approved.
In my form when approver selects the option either approved or reject, the result will get save in the approved field.
Now I want to change the status field also as per the result save in the approved field to Approved or Rejected.
I tried this by using update item action in power automate flow and it is not working. It is calling the same thing in a loop. It is also showing warning that this action will trigger an infinite loop.
Can anyone please suggest me any solution with this action in flow.
You can add trigger conditions to your flow so that it will only fire when a specific set of conditions are met.
This is a basic example that you can try and incorporate into your own flow.
My list has two specific fields, Field1 and Field2. As per your trigger, when an item is created or modified, I only want to trigger the flow when those two fields are not equal and if they're not, the flow will update Field2 with the value from Field1.
This removes the recursive nature of the flow as it will do the check prior to actually executing.
My expression for the trigger is shown below ...
... and that setting can be found in the settings of the trigger ...
I have a Data Factory pipeline that perfroms some pretty simple tasks. For somereason, the Logic App portion of the pipeline is "firing" multiple times, even thouh I'm calling it just once.
So, the pipeline runs three stored procedures. It then exports the results to a Data Lake container. Then lastly, it send an email with the three reports as attachmentsin an email.
I have everything working fine, but there is one odd bit of behavior I'm seeing. The logic app is essentially firing three times when it's called, so I end up getting three emails. It looks like I'm doing everything right.
Logic App Designer
Logic App
I seems as though it's firing for each attachment / blob content action. I'm fresh out of ideas. If anyone has any thoughts, that would be awesome.
Thank you!
The trigger will be fired if you add/modify the files in the folder which you specified every x minutes(you set it 3 minutes). And if you added/modified three files, the trigger will be fired three times, so you received three emails. You can take a look the runs history of your logic app, every time running the "Body" of the trigger will return one file content of the three files.
If you don't want the flow run three three times, you can set the trigger by following steps below:
Change the "Number of blobs to return from the trigger" to 10 (or any number which you want, but should be greater 3 as you have three files).
Click the ... button at the upper right-hand corner of the trigger and click "Settings", disable "Split On".
After completing the two steps of setting, the "Body" of trigger will return all of the three files in one time, you will receive only one email.
Update:
Sorry for missing one step, apart from the steps above we also need to add a "If" condition in the logic app.
Create a "If" condition after the "When a blob is added or modified (properties only)" trigger, the details of the condition shown as below:
If true, do the steps what you want(such as get the blob content and send emails). If false, do nothing. Then you will just receive one email.
By the way, if you notice the run history, you can see the logic app was triggered two times. In first time, the trigger response the "body" with a [] array and in second time the trigger response the "body" with three blob array. This is why we need to add the "If" condition.
We've a SQL server stored procedure which returns the incremental records. If there are no changes to the table, then nothing is returned. Stored procedure does what is expected.
We're invoking the above said stored procedure via Copy activity in Azure data factory. It works fine for all the cases except when nothing (empty) is returned.
We are looking for an option, where Nothing(Empty) is returned from stored procedure, pipeline should skip and proceed further and also mark the whole pipeline successful rather failed.
Thanks
Your stored procedure needs to end by a SELECT, so it returns something - including an empty set if there is no rows to return.
However, to skip the pipeline if there is no row, DraganB's last answer is pretty relevant, I had to do that a couple of time on my current project.
As #DraganB said in the comment, activities could run in the flow,so you could do stored procedure activity --> if activity --> copy activity.If the output of sp activity is empty,then don't run the copy activity and end the pipeline.
Another idea, maybe you could learn about azure function external table trigger. You could add a status column in your table such as needToBeCopied, every insert or update operation will change the column. Then filter the data which need to be copied while running the copy activity.
It got resolved. The real issue was Copy activity wasn't returning the correct error message. There was an issue with access control.
Grant VIEW CHANGE TRACKING permission on a table to a user:
[sql]
GRANT VIEW CHANGE TRACKING ON OBJECT::dbo.databaselog to username
[/sql]
Incremental loading approach is through enabling Change Tracking on SQL Server Database and on required tables .
Azure data factory should have logged error as 'Insufficient permissions on so and so table'. Instead it failed the whole pipeline with error message as 'Stored procedure might be invalid or stored procedure doesn't return any output'.
Anyway, we assigned the right permissions and issue got resolved. Now, it creates an Empty file just with header record in it when there's no output returned from Stored Procedure likewise in - Data Factory Avoiding creation of empty files
We have a C++ legacy application that connects to an Oracle 11g database. The application uses Microsoft Data Access Objects (DAO) library to allow record browsing and modification. We also have some triggers on tables to track row updates and insertions.
The problem is that the triggers don't fire for the CLOB columns that we have in our tables. It gets fired for other columns but for this one CLOB column, it neither fires during update nor during delete. I've added the trigger for all three: UPDATE, INSERT and DELETE.
Is there some option that manages triggers for CLOBs? Or some other setting that might be affecting this? Any ideas where should I look for a solution?
I found a possible explanation to this non-firing trigger:
Your trigger actually works -- WHEN it is fired!
The problem is -- you are NOT updating the table when you set the lob value. You might be modifying the lob contents but -- and this is key -- you are NOT modifying the lob locator in the table itself. The row values of the table are not changing, the trigger does NOT fire for the dbms_lob.copy (or write, or trim, or append, or ...)
I think the solution proposed here at askTom requires to have a specific procedure but I haven't quite understand it.