Step 2: Add below JS in the same power page to capture the pushed recordId, this inserts the recordId in the browser URL, and also adds it to iFrame src url. If the below js code does not work, just replace it with a js code that captures the browser url parameter and assign it to iFrame src. Add the below function in script tag.
(function() {
const iframeId = "MyAppFrame"; // MUST match the iframe id below
const allowedOrigins = [
"https://apps.powerapps.com", // Power Apps host
location.origin // Your portal origin (safety default)
];
function isAllowedOrigin(origin) {
// Relax this list if needed; keeping '*' is easiest but unsafe
return allowedOrigins.some(o => origin.startsWith(o));
}
window.addEventListener("message", function (e) {
try {
if (!e || !e.data) return;
// SECURITY: optionally check origin
// if (!isAllowedOrigin(e.origin)) return;
const recId = e.data.recordId ?? e.data.RecordId ?? e.data.recordid;
if (!recId) return;
// Update browser URL (no page reload)
const url = new URL(window.location.href);
url.searchParams.set("RecordId", recId);
history.replaceState({}, "", url.toString());
// Update iFrame src so embedded app receives Param("RecordId")
const iframe = document.getElementById(iframeId);
if (!iframe) return;
const base = "https://apps.powerapps.com/play/<appid>";
const qs = [
"RecordId=" + encodeURIComponent(recId),
"hidenavbar=true", // optional UX
"source=portal" // optional marker
].join("&");
// Preserve existing hash if present
const hash = iframe.src.includes("#") ? iframe.src.split("#")[1] : "";
iframe.src = base + "?" + qs + (hash ? "#" + hash : "");
} catch (err) {
console.error("Deep-link handler error:", err);
}
}, false);
})();
Step 3: Modify your iframe as below to capture the RecordId
<iframe
id="myiframe"
width="100%"
height="900px"
src="https://apps.powerapps.com/play/<appid>?recordId={{ request.params['recordId'] }}"
frameborder="0">
</iframe>
Step 4: Update the StartScreen/OnStart (whatever applicable) property for param check and navigation to EvidenceScreen if RecordId available, something like this:
// App.StartScreen
If(
!IsBlank(Param("RecordId")),
EvidenceScreen, // go straight to Details
LandingScreen // default
)
If it works, then you will have an issue of navigating back to landing page. You need to clear the url (recordId) from the browser, otherwise you will be always navigated to evidence page.
Hope it works!