I'm trying to create an Azure Logic API that calls API1, gets a list of IDs then passes those IDs into another API call to API2 to see if the ID already exists. If it does not I want it to create the ID in API2.
I've set it up as a timer-base trigger. When triggered I have it making an API request to get a list of IDs from the first API. It then parses the JSON so that I can use the IDs in a Foreach loop to take the IDs from one API and compare them with IDs from another API. It's then parsing the JSON response for another foreach loop to evaluate if it exists then skip and if it doesn't create the new IDs.
The problem I'm having is when it doesn't exist in the second API it never kicks off the API request to create the IDs in the second API. The most logical way to set it up is if API1-ID does not equal API2-ID, then true otherwise false. The problem is, if the ID doesn't exist in API2 there's nothing to evaluate for true/false so the API call to create never execute. I had assumed that if ID didn't exists then it wasn't equal, so it would be true.
I've even tried to use the empty expression or length if the JSON response body is zero, but I cannot get this fire off the API request to create the missing IDs. I feel like this can work because I've flipped it to where if ID = ID then it creates the ID (which gives me duplicates).
If anyone can help that would be awesome!
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.
The current Zapier steps i have set up creates a GET request to an external service. that service replies with a list of data that is nested. My end step i need to do is make multiple PUT requests to another API with part of the URL being a value from the response from the GET. There is not a fixed number of id’s/times that it will need to PUT.
Currently if i do it with just the GET then the next step is the PUT it puts all of the values of the ID i need to put at the end of the API url as just a comma separated list. I need them to make separate PUT requests for Each ID.
Any help would be greatly appreciated.
This shows the response to the GET request (Images shows only the first part. There will are more in the response)
This is the PUT request. It currently puts them as a comma separated list. which causes an error. each of the values needs to process as a separate PUT.
You may want to consider writing your own code step to format the nested data into an array of objects (JSON). You could then return the data to output and achieve the effect you're looking for, where the next Step runs a PUT request for each item in your output array.
Here are Zapier's notes on this strategy:
Setting the output to an array of objects will run the subsequent steps multiple times — once for each object in the array. If Code by Zapier is the Zap's trigger and an empty array is returned, nothing happens. You can think of it like a polling trigger that did not get any results in the HTTP response. This functionality is exclusive to triggers — returning an empty array in a Code by Zapier action does not have the same effect.
I have a view function that needs to gather multiple pieces of information in one call (it's a quick outbound call - the user answers and is to be immediately prompted for these data points), based on data pulled from a DB. What I'd like the view function to do is something like the following:
group_id = <get group id>
params = data_element_select_params.DataElementSelectParams(group_id=group_id)
data_elements = worker.select(params) # function I wrote which returns a list of objects, in this case objects called DataElements
vr = VoiceResponse()
say_msg = 'Enter {element}, then press star.'
for element in data_elements:
say_message = say_msg.format(element=element.name)
<Gather input with say_message and save it>
Can this be achieved without routing to the same URL over and over? I have not seen any other solution, and I'd rather not continually redirect to the same URL as we'll have to pull the list of elements from the DB again for each element.
Apologies if anything is unclear - please point it out and I'll clarify as quickly as I can.
Twilio developer evangelist here.
You can only use one <Gather> per TwiML document, so no, you can't ask multiple questions and take multiple inputs within the one webhook.
You will need to route to a URL that receives the input from each <Gather> and then asks the next question.
To avoid pulling all the elements from the DB every time, you could investigate saving the elements to the HTTP session and pulling them back out of there. Twilio is a well behaved HTTP client, so you can use things like cookies to store information about the current call/conversation.
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.
I'm doing an add list request with multiple records getting passed to it. I need to be able to get the internal IDs of the records that get created as a result of my request. I know those come back in the write responses that get returned. However, my question is if the responses come back in the same order as the records I pass in the request. If not, then how will I know which response corresponds with which record?
Try passing the ID of the item in the external ID field. I don't know if the recordRef returned will return both the internal ID and external ID or not. It may. If so, you will be able to tie the external ID back to your item in the list.