Hi there,
This is a very interesting scenario, and I understand the challenge you're facing with session control and timing between page refresh and navigation.
Here are a few suggestions that might help:
1. Use a Polling Mechanism in Business Central
Since the Power Automate flow inserts data asynchronously, you could implement a lightweight polling mechanism on the card page using AL code. This would periodically check for the presence of the new data and trigger a refresh or navigation once the condition is met.
2. Leverage JavaScript Add-ins
If you're using a browser-based session, consider using a JavaScript control add-in. This can help you:
- Maintain control over the session.
- Trigger a refresh of the card page.
- Open another page (like the Purchase Order) after confirming the refresh is complete.
You can use window.open() for the PO page and location.reload() for the card page, but ensure the timing is managed correctly—perhaps using Promises or async/await logic in JS.
3. Split the Flow Logic
Instead of trying to do both actions in one go, consider splitting the logic:
- First, let the Power Automate flow insert the data.
- Then, have a separate trigger (e.g., a button or a timed event) on the card page that checks for the inserted data and opens the PO page only after confirming the refresh.
4. Use a Message Queue or SignalR
For more advanced scenarios, you could use a message queue or real-time communication (like SignalR) to notify the client when the data insertion is complete. This would allow the card page to react in real time without polling.
Let me know if you'd like help with implementing any of these approaches or if you can share more details about the environment you're working in (e.g., AL, extensions, JS add-ins).
If this answer was helpful, please consider marking it as accepted.
Best of luck with your integration!
Warm regards,
Daniele