web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Run Javascript functio...
Power Automate
Answered

Run Javascript function on a browser gives syntax error

(0) ShareShare
ReportReport
Posted on by 12

Hi ,

 

When i am try to paste my code inside run JavaScript function on a browser activity, it is giving syntax error, while the same code is executable on other IDE.
For  the time being i am using this via reading the code from a text file then pasting it in JavaScript activity.
But since this will involve dependency on a file and i need to get rid of this dependency , so kindly suggest what could be the reason of this syntax error, or if there is an alternative of this read from file without involving any dependency on external file.
I have tried using str variable , it also gives Invalid value when i paste my code in it.


Below is my js code 

function openModal() {

let BasicModalData = document.createElement('div');
BasicModalData.setAttribute('id', 'BasicModalData');

BasicModalData.innerHTML = `
<style>
/* Styles for the modal */
.modal {

position: fixed;
top: 50%;
left: 50%;
border: 1px solid #888;
margin-left: 25px;
padding: 20px 20px;
text-align: Center;
transform: translate(-50%, -50%);
z-index: 1000;
display: block;
border: 1px solid #888;
width: 40%;
margin: auto;
height:25%;
background-color: AliceBlue;
font-family: 'Monaco', Monospace;
font-size: 25px;
font-weight: bold

}

.button-container { text-align: center; position: absolute; bottom: 10px; width: 100%; }
.button-container input { margin-right: 16px; }
</style>

<!-- Modal -->
<div id="BasicModal" class="modal">

<p>Virtual Bot Voluntary Changes Execution Started......</p>

<div class="button-container">
<button onclick="closeModal()">Close</button>
</div>
</div>

`;


let existingFlightData = document.getElementById('FlightData');
if (existingFlightData) {
document.body.removeChild(existingFlightData);
}
let BasicModaldata = document.getElementById('BasicModalData');
if (BasicModaldata) {
document.body.removeChild(BasicModalData);
}

document.body.appendChild(BasicModalData);

document.getElementById('BasicModalData').style.display = 'block';
setTimeout(function() {
closeModal();
}, 3000);
}

 

function closeModal() {
let basicModalData = document.getElementById('BasicModalData');
if (basicModalData) {
basicModalData.style.display = 'none';
document.body.removeChild(basicModalData);
}
}

openModal();

  • Verified answer
    eetuRobo Profile Picture
    4,607 Super User 2026 Season 2 on at

    In Power Automate Desktop % -signs are used around variables.
    You need to add another % -sign after so it reads it as one precent sign.
    So change all % -> %%

    eetuRobo_0-1703755274634.png

     

  • kje039 Profile Picture
    12 on at

    Thanks eetuRobo,
    The solution worked now i am able to write the complete code inside the block.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 315 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 267

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard