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>

Report
All responses (
Answers (