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

Notifications

Announcements

Community site session details

Community site session details

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

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();

I have the same question (0)
  • Verified answer
    eetuRobo Profile Picture
    4,204 Super User 2025 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard