Sometimes we find it much easier to write some code to do simple or even more complex tasks within a PopFlow. Either way, we have the flexibility to support code blocks in PopFlow.
Incorporating code within PopFlows is accomplished using two activities.
Check out all the example in this lesson, and the PopFlow used.
Example of Run Javascript Activity
The activity allows you to insert your own Javascript in your PopFlow.
Running the basic test above, you will be prompted with three message alerts:
A quick intro and hello!
Prompting for your name
Displaying your name
Using the same example above, we can save yourName into a variable used further downstream in a PopFlow.
Let's first show what happens when you attempt to access yourName outside the “Initial Activity” or code block it was originally used within.
alert (yourName)
Now run the test and view the Inspector's results. You should have now seen Four Alert Messages. However, you only saw three because we failed the last Run Javascript step.
While the approach theoretically works, activities that come after it, even several steps away, won't be aware of the results because the "Run Javascript" activity executes its own Javascript.
We need to pass data into a “tempDataState” variable, to resolve this.
2. Then edit the next Run Javascript to include:
3. Re-Test!
Running the basic test above, you will be prompted with four message alerts:
A quick intro and hello!
Prompting for your name
Displaying your name
Example of Data from Prev. Step showing in New Step
The Dynamic UI is extremely flexible and allows users to write HTML directly into their PopFlow ScreenPops.
HTML can beautify screens, modals, and provide a cleaner experience when interacting with the CRM and User. To further our tests above, we'll implement a ScreenPop that takes the information directly from our Javascript example and displays it into a Modal on the CRM.
Previewing the HTML is easy:
The above helps adjust the Modal width, height, and overall previewing information displayed from the HTML code.
You can always use pre-packaged HTML and uses information from “Set Value” activities to drive its content. This is helpful for those who do not want to edit HTML, understand HTML, and would like to benefit from common use cases using ScreenPop.
Example Code:
Note we've already added yourName into the HTML to show you how you can incorporate the value.
The “interaction” is the execution of a PopFlow. In short, the data saved in the tempData element is only accessible during the life of the said interaction (PopFlow) and does not live outside of the interaction.
Make sure to see the example “Updating Browsers LocalStorage” to see how you could leverage a bit more information directly into the browser.
Here we are setting the currently active calls (using a callID) into localstorage. While we clear this at the end of the call, it can be used by other PopFlows (e.g. OnTabChange & OnTabSave) to update the attached data for contextual screen pop.
In the next block, you can see that we are reading the stored value for consumption by the OnTabSave workflow to update the screen pop table for transfers in Oracle.
The below is how we used JavaScript to encrypt the comment before posting it to the CRM.