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 Apps / App link is not workin...
Power Apps
Unanswered

App link is not working from SharePoint

(0) ShareShare
ReportReport
Posted on by 6

I have a powerapp that is launched from a JS link on a SPO site page.

 

When I click the link to the app, it works.

When another user clicks the same link to the app, it just spins.  User can login to powerapps, and see the app listed.  And launch it.  (App requires a parameter)  But when they click the link on the SP page, it tries to load powerapps, but it just spins with the blue circle of death.

 

If I give the user a direct link to the app manually adding the parameter, IT WORKS! (Why?)

 

I had the user add all the powerapps domain from this link.
https://support.microsoft.com/en-us/help/4023606/troubleshooting-startup-issues-in-powerapps-web-authoring#R2

 

 

Here is the JS code for the link.  Again, works fine for me, not the user.

 

 

<script type="text/javascript">
 document.addEventListener("DOMContentLoaded", function (event) {
 var a = document.getElementById("idDocSetPropertiesWebPart");
 if (a) {
 var b = a.getElementsByTagName("tr")[4]
 if (b) {
 var c = b.getElementsByTagName("td")[2];
 if (c) {
					c.innerHTML = "<pre class=\"ms-headerFont ms-standardheader\">" + c.innerHTML + "</pre>";
 }
 }
 }
 });
</script>
<script type="text/javascript">
 function getCurrentItem(context, web, list, success, error) {
 // Get List Item ID
 var itemId = parseInt(GetUrlKeyValue('ID'));
 var listItem = list.getItemById(itemId);

		// Load context
 context.load(listItem);

		// Execute query
		context.executeQueryAsync(
			function () {
				success(listItem);
			},
			error
		);
 }

	function getCurrentTasks(context, web, list, success, error) {
		var itemId = parseInt(GetUrlKeyValue('ID'));
		var query = new SP.CamlQuery();
		var viewXml = "<View><Query><Where><And><Eq><FieldRef Name='AssignedTo' LookupId='TRUE' /><Value Type='Integer'><UserID /></Value></Eq><Eq><FieldRef Name='WorkflowItemId' /><Value Type='Integer'>" + itemId + "</Value></Eq></And></Where><OrderBy><FieldRef Name='Created' Ascending='FALSE'/></OrderBy></Query><RowLimit>1</RowLimit></View>";
		query.set_viewXml(viewXml);

		listItems = list.getItems(query);

		//Load context
		context.load(listItems);

		//Execute query
		context.executeQueryAsync(function () { success(listItems); }, Function.createDelegate(this, error));
	}

 function StartWorkflow() {
 var context = SP.ClientContext.get_current();
 var web = context.get_web();

 // Get List
 var listGuid = _spPageContextInfo.pageListId;
 var list = web.get_lists().getById(listGuid);

 // Get List Item ID
 var itemId = parseInt(GetUrlKeyValue('ID'));

 getCurrentItem(context, web, list, function (listItem) {
 var itemGuid = listItem.get_item("GUID");

 //Workflow Services Manager
 var wfServicesManager = new SP.WorkflowServices.WorkflowServicesManager(context, web);

 //Workflow Interop Service used to interact with SharePoint 2010 Engine Workflows
 var interopService = wfServicesManager.getWorkflowInteropService()

 //Initiation Parameters have to be in a plain JS Object.
 var initiationParameters = {};

 //Start the Site Workflow by Passing the name of the Workflow and the initiation Parameters.
 var result = interopService.startWorkflow("Ready for Approval", SP.Guid.newGuid(), listGuid, itemGuid, initiationParameters);
 context.executeQueryAsync(
 function (sender, args) {
 alert("This CAR has been successfully submitted for approval.");
 },
 function () {
 alert("Error starting workflow. Please notify Jeannie manually.")
 });
 },
 function () {
 alert("Error getting list item.");
 }
 );
 }

 function ButtonClicked() {
 SP.SOD.executeFunc("sp.js", "SP.ClientContext", function () {
 SP.SOD.registerSod('sp.workflowservices.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.workflowservices.js'));
 SP.SOD.executeFunc('sp.workflowservices.js', "SP.WorkflowServices.WorkflowServicesManager", StartWorkflow);
 });
 }
	function btnAdminClicked() {
		var listGuid = _spPageContextInfo.pageListId;
		var itemId = parseInt(GetUrlKeyValue('ID'));

		window.location.href = "https://web.powerapps.com/apps/d4019a4a-c38f-4b57-9aaa-925cd81f5f9c?itemid=" + itemId;
 }
 function btnApprovalsClicked() {
 window.location.href = "https://us.flow.microsoft.com/manage/environments/Default-3b714df2-68c1-4ec5-bbb9-07273d9df641/approvals/received";
 }
 function btnQuestionsClicked() {
 var listGuid = _spPageContextInfo.pageListId;
 var itemId = parseInt(GetUrlKeyValue('ID'));

 window.location.href = "https://web.powerapps.com/apps/251d5352-3630-44cf-87fe-b42ddcad0dad?CARID=" + itemId;
 }


</script>

<button id="btnReadyForApproval" onclick="ButtonClicked()" style="width:130px; margin-left:0px;" disabled="disabled">Ready to Submit</button>
<input type='button' id="btnApprovals" onclick="btnApprovalsClicked()" style="width:130px; margin-left:0px;" value='Approvals' />
<input type='button' id="btnAdmin" onclick="btnAdminClicked()" style="width:130px; margin-left:0px;" value='Admin' />
<input type='button' id="btnQuestions" onclick="btnQuestionsClicked()" style="width:130px; margin-left:0px;" value='Questions' />

<script type="text/javascript">
 window.onload = function () {
 var context = SP.ClientContext.get_current();
 var web = context.get_web();

 var listGuid = _spPageContextInfo.pageListId;
 var carList = web.get_lists().getById(listGuid);

 getCurrentItem(context, web, carList, function (listItem) {
 var status = listItem.get_item("CARStatus");
 if (status == "Draft" || status == "Rejected") {
 document.getElementById('btnReadyForApproval').disabled = false;
 } else {
 document.getElementById('btnReadyForApproval').disabled = true;
 }
 },
 function () {

 });

		var taskList = web.get_lists().getByTitle("Tasks");
		context.load(taskList, 'Id');
		getCurrentTasks(context, web, taskList,
		function(listItems) {
			var enumerator = listItems.getEnumerator();
			while(enumerator.moveNext()) {
				var item = enumerator.get_current();
				var listId = taskList.get_id();
				var itemId = item.get_id();

				var button = document.createElement('input');
				button.type = 'button';
				button.style = "width:130px; margin-left:5px;";
				button.onclick = function () { btnTaskClicked(listId, itemId); };
				button.value = "Task";

				var approvalButton = document.getElementById('btnApprovals');
				approvalButton.parentNode.insertBefore(button, approvalButton.nextSibling);
			}
		},
		function (sender, args) {});
 }
</script>
I have the same question (0)
  • NachoMas Profile Picture
    6 on at

    Consider this resolved.  I found that the content type had not pushed down the changes to the document set that has the link.  So it was really a SharePoint problem.  I was fooled by the fact that the wrong linked worked for me, but the app looked exactly the same. (dev vs prod)  I looked at the page source to determine that it was in fact the wrong link.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard