Embedded interfaces can provide solutions for Appian customers for a variety of reasons. One such use case involves a customer that has an existing external facing portal with branding and legacy functionality that they currently direct their customers to, and want to enhance with Appian’s low-code capabilities.
Embedded Appian interfaces provide a broad array of functionality, and can require JavaScript coding to achieve the desired end user experience. Specifically, JavaScript events need to be implemented and handled in order to replicate a typical Tempo/Sites user experience where the user clicks a task link and does not navigate away from the page. This playbook play will center around getting an embedded task report with this Tempo/Sites behavior up and running as quickly as possible, and provide functionality similar to that of a Tempo/Sites Appian application.
After successfully implementing this playbook play, you will be able to:
Before you can embed any Appian interfaces, there are a few considerations to keep in mind:
The following sections explain how to implement your first embedded interface into your own webpage. An example application can be downloaded and is available on Appian Forum. (Note: this Playbook play assumes the user has advanced Appian designer knowledge and basic web developer skills. If any concepts or terms are unclear, please complete the “Designer” trainings available in Appian Academy. Also, please keep in mind that we would only recommend completing this exercise in a development environment. We don't recommend this exercise be done in a customer portal.)
Deploy the file "index.html" in the web server. If the file is deployed under a nested folder/path, you will need to use the full path to this file in the following steps.
The remainder of this playbook will reference “localhost:4200”.
Once CORS is set up correctly, accessing the site with the embedded interface can be done via a web browser using the same address specified in the CORS settings. If you are not currently logged into Appian, you will be presented with the Appian login screen.
After logging in, you will see the task report hosted, and ready to interact with (provided you kicked off tasks in step 3 of the Appian Setup section):
Note that clicking a task will make it appear underneath the “My Tasks” task report. Submitting the task will make it disappear from the “My Tasks” report.
If it would be preferred that the task report disappears and is replaced by the task instead, simply comment out the lines mentioned in step 3 of the HTML/JavaScript Code section.
<!doctype html> <html lang="en"> <head> <!-- Web browser auto-refresh functionality (every 30 seconds) <meta http-equiv="refresh" content="30">--> <meta charset="utf-8"> <title>Embedded SAIL Playbook Demo</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" type="image/x-icon" href="favicon.ico"> <!---Required embeddedBootstrap tag---> <script src="https://ps-sandbox1.appiancloud.com/suite/tempo/ui/sail-client/embeddedBootstrap.nocache.js" id="appianEmbedded"></script> <script> //Replace with relevant task report URL stub const reportURLStub = '-OmqXw'; window.onload = function () { var reportInsertDiv = document.getElementById('reportInsertPoint'); var newReport = document.createElement("appian-report"); newReport.setAttribute("reportUrlStub", reportURLStub); newReport.setAttribute("id", "embeddedTaskReport"); reportInsertDiv.appendChild(newReport); // Event listener for links clicked on task report document.getElementById("embeddedTaskReport") .addEventListener( "open-task-link", (event) => {taskLinkClicked(event);}, false ); } // This function handles the behavior of the task when the task link is selected from the task report. function taskLinkClicked(event) { event.preventDefault(); console.log("The task link has been clicked! " + event.detail.taskId ); //Uncommenting lines 41-44 will provide the behavior of replacing the task report with the task itself. //On completion of the task it will re-display the task report. // var reportInsertDiv = document.getElementById('reportInsertPoint'); // var reportChild = document.getElementById('reportInsertPoint').children[0]; // var newReport = document.createElement("p"); // reportInsertDiv.replaceChild(newReport, reportChild); var taskInsertDiv = document.getElementById('taskInsertPoint'); var taskChild = document.getElementById('taskInsertPoint').children[0]; var newTask = document.createElement('appian-task'); newTask.setAttribute("taskId", event.detail.taskId); newTask.addEventListener("submit", handleSubmit, false); taskInsertDiv.replaceChild(newTask, taskChild); } function handleSubmit() { var insertDiv = document.getElementById('taskInsertPoint'); var child = document.getElementById('taskInsertPoint').children[0]; var paragraph = document.createElement("p"); insertDiv.replaceChild(paragraph, child); var reportInsertDiv = document.getElementById('reportInsertPoint'); var reportChild = document.getElementById('reportInsertPoint').children[0]; var newReport = document.createElement("appian-report"); newReport.setAttribute("reportUrlStub", reportURLStub); newReport.setAttribute("id", "embeddedTaskReport"); reportInsertDiv.replaceChild(newReport, reportChild); document.getElementById("embeddedTaskReport") .addEventListener( "open-task-link", (event) => {taskLinkClicked(event);}, false ); } </script> </head> <body> <div id="reportInsertPoint"></div> <div id="taskInsertPoint"> <div id="taskInsertPointChild"/> </div> </body> </html>
6431.Embedded UI Demo.zip
8863.index.zip