3 Replies Latest reply: Sep 29, 2014 12:31 PM by Russ_E RSS

    How to pass arguments into a Captivate project

    Pkoel Community Member

      Hello,

       

         We use dotNetNuke (DNN) as our Content Management System. We are using tokens in DNN to personalize the screens. We have access to the uses first name and email. I would like to pass this information into a Captivate project. I have seen references in my research to using Javascript to invoke the Captivate project, but I have not found any samples of the source code, nor examples of how to use the passed values in the Captivate presentation.  Can someone validate that this functionality exists for Captivate 8 and perhaps point me to a few examples?

       

      Thanks,

       

      Peter

        • 1. Re: How to pass arguments into a Captivate project
          Russ_E Community Member

          There are a few ways to do it, both automated and manual.

          I am assuming you are outputting as html5 here.

           

          But this is a simple manual way.

          1.

          create a variable in cp to hold your value. (e.g. holdName)

           

          2.

          add js to the page (after you export it)

           

          //check if window.cpAPIInterface is available and ready

          if(window.cpAPIInterface)

          {

               //assign your value to the cp variable you created in the project

                 window.cpAPIInterface.setVariableValue("holdName",whatevervalueyouarepassing);

          }

           

          Hope that makes sense and helps.

           

          Russ

          • 2. Re: How to pass arguments into a Captivate project
            Pkoel Community Member

            Hi Russ,

             

               Thanks for the fast response. I added the following code to the

            index.html page of my published project:

               

                    if(window.cpAPIInterface)

                    {

                        window.cpAPIInterface.setVariableValue("holdName",

            );

                    }

                </script>

             

            Where  is the DNN token I want to pass to the Captivate

            project. The syntax for the token I got from a DNN website.

             

            I also tried putting a quoted string in place of the token just to see if

            it would pass something; and it was a no-go. Any ideas?

             

            Thanks,

             

            Peter

            • 3. Re: How to pass arguments into a Captivate project
              Russ_E Community Member

              Sorry. I think I was a bit too vague in my answer.

              And I don't know about how you are getting your token value, but that part is up to you.

              Just make sure to put it in place of where I wrote "whateveryourtokenvalueiscalled".

               

              1.

              create a variable in cp to hold your value. (e.g. holdName)


              2.

              Add this inside the <head></head> tags of your page (after you export it):

              <script>

                   function = getMyValues () {

                        if(window.cpAPIInterface)

                        {

                             //assign your token value to the cp variable you created in the project

                             window.cpAPIInterface.setVariableValue("holdName",whateveryourtokenvalueiscalled);

                        }

                   }

              </script>

              3.

              Back in your cp project, call to the function at some point.

              For example, on page 2, add to the page's action

              On Enter:

                   Execute Javascript

              Then in the script window, type this to start up the function:

              getMyValues();

               

              I hope that makes sense.  I'm not really great at explaining scripting unfortunately.