Forum Discussion

ScottMcGee-daa8's avatar
ScottMcGee-daa8
Community Member
31 days ago
Solved

Importing variables from excel online (Power Automate / Json)

I've seen some people pull in data from sheets, using google sheets, which is exactly what I want to do....But....

The company I work for doesn't allow access to google sheets and are strict on third party plugins and software.

After some research I found this tutorial to input data to an excel spreadsheet.

https://www.youtube.com/watch?v=nPpjfW-Zo10

I got this working fine, but I want to be able to pluck the data back out and put it into a seperate SL module on our LMS.

What I want to achieve is someone in Part 1 answers how confident they feel about a specific subject, before completing several modules over several weeks. 

Then Part 2 would be similar to part 1 asking them how they confidently feel now, but it would their answers from part 1. 

example: You said when you first start that you "don't feel confident" about you understanding of....... How do you feel now after completing the training.

  • Shouldn't be difficult I am sure there is a power automate that can retrieve data based off of a unique ID and then send back to Storyline

    • ScottMcGee-daa8's avatar
      ScottMcGee-daa8
      Community Member
      // Function to retrieve the profile and set variables in Storyline async function retrieveProfile() { var player = parent.GetPlayer(); // Initialize player here try { // Access the storyline player object function findLMSAPI(win) { // look in this window if (win.hasOwnProperty("GetStudentID")) return win; // all done if no parent else if (win.parent == win) return null; // climb up to parent window & look there else return findLMSAPI(win.parent); } var lmsAPI = findLMSAPI(this); var sID = lmsAPI.GetStudentID(); console.log("Email Address from Storyline:", myEmail); // Debugging log // Power Automate URL var url = "Put your URL here"; // Send the POST request to Power Automate let response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: sID }) // Payload with email }); // Parse the JSON response let data = await response.json(); console.log("Response from Power Automate:", data); // Debugging log if (response.ok && data.success) { console.log("Profile retrieved successfully!"); // Helper function to handle boolean conversion function toBoolean(value) { if (value === "TRUE" || value === "true" || value === true) return true; return false; } // Set variables in Storyline from the response // Example 1 player.SetVar("variable 1", true); // Example 2 player.SetVar("variable 2", toBoolean(data.purpose1)); // Delay the setting of ProfileCreated to "Loaded" to allow time for the variables to update setTimeout(function() { player.SetVar("ProfileCreated", "Loaded"); console.log("ProfileCreated Variable set to 'loaded'."); }, 1500); // 500 millisecond delay } else { console.log("Profile not found or error in response."); player.SetVar("ProfileCreated", "Profile Not Found"); } } catch (error) { console.error("Error retrieving profile:", error); player.SetVar("ProfileCreated", "Error"); } } // Trigger the function when the page loads window.onload = retrieveProfile;

      Tia Pez did this video breakdown for me that's on Storyline fb forum, although the link is in Loom. I can't seem to share it. So I've posted the script in the reply. I've alter a few variables. So apologies if it requires a once over, but it should work for anyone using it via an LMS if they don't have CORS policy stoppi

      Unfortunately and I'm in the process of asking our security team if they'll allow this access to retrieve. If not, then although this might help some others. I ran into a dead end as I have no other way to store/retreive the data at a later date.