New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to check published status in Flow #16674
Comments
My suggestion for resolution would be to improve the documentation for Flows, perhaps by adding a Guide with all the details necessary to have a working example of how to control a Flow based on published status. I will share my Flow in case this is helpful. My use case is I want a manual trigger that when clicked will create a Campaign in my Listmonk instance, but only if the item is published. Step 1: Create a CollectionCreate a Collection called "Post" with fields:
Step 2: Create a FlowName: Create Campaign Step 3: Read Data OperationThis step is to retrieve the item so the data can be used within the Flow. This is why its the first step. Name: Get Item
Emit Events: (not enabled) Step 4: Run Script Operation to check if publishedThis step is to ensure the flow exits if the content is not in a published state. Name: Is Published
Step 5: Run Script Operation to prepare request bodyThis step is necessary to ensure the request body is formatted correctly. (You could simply do this in the request step, but when I did that the request body was malformed. I presume this is because doing it in the request step is embedding a JSON string within another JSON string as opposed to this approach which takes an object and serializes it into JSON, which is probably safer all around.) Name: Prepare Body
Step 6: Run Script Operation to check if request body is OKThis step is to ensure the flow exits if preparing the request body errored. Name: Is Body OK
Step 7: Webhook / Request URL to create the campaign in ListmonkThis step is to make the HTTP request to create a campaign in Listmonk using the processed request body. Name: Create Campaign
Request Body:
Bonus: Send notification on failureAt each step, you can send a notification on failure by creating an operation and connecting it to the failure on a step. I used an email notification since I couldn't figure out how to send an in-app notification to the user who triggered it. (If I figure that out I'll edit this post.) Name: Send Notification
Another tip is that on the failure to send to API you can include the request information in the email (I couldn't figure out how to get the request response):
Edit 11/29 3pm ET: Using a Send Notification operation with User value of |
Using the great and detailed examples provided (thanks 😄) i attempted to recreate your error situation since #16483 was fixed but with no success unfortunately. Flow: Closing the issue for now but am happy to re-open if we can get it reproducable. |
Tagging in @erondpowell for the docs |
Thanks @br41nslug, that comment was very helpful! The A clarification...This is in a collapsible because it's not a necessary comment. But, in case this is helpful, I wanted to clarify: at the time of submitting this issue I had a functional solution. The "bug" I am presenting is that it took me a subjectively long time to get to a working solution due to (a) my own lack of knowledge of Directus (which is true, I am a novice with Directus), or (b) a lack of sufficient documentation in the area of Flows, or perhaps a combination. I chose "bug" because I didn't see an issue type I could classify this under, but in retrospect perhaps this would be better suited as a Feature Request. In my mind, I thought of a Feature Request as code-only, but I can see that applying to documentation too.Specifically, what I hope is shown in the docs is that a Flow doesn't have the item's content with it, just the ID. You have to do a lookup using To achieve this clarity, some options could be:
I would be very happy to contribute to any of those options or some other option, I just need a nudge in the right direction. I see Guides are not part of the docs, so perhaps I would write it in a Google Doc and share it. But, maybe this isn't best as a guide and instead a cookbook, or just enhancing existing docs. PS. Flows are amazing. Thanks to everyone involved in making Directus such top-notch software. |
Describe the Bug
Following existing documentation I could not check the published status of an item using a manual Flow.
The documentation I found that covers Flows includes:
To Reproduce
Errors Shown
Depending on the Operation of choice: the condition may always pass (see recent fix for a related issue), or the condition may always fail.
What version of Directus are you using?
9.21.0
What version of Node.js are you using?
16.18.1
What database are you using?
MySQL 8.0.31
What browser are you using?
Firefox
How are you deploying Directus?
Docker
The text was updated successfully, but these errors were encountered: