Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Adding JavaScript code to Pega Platform applications

Updated on February 23, 2022

Customize how your offline offline-enabled mobile app stores and synchronizes data by adding JavaScript code to your Pega Platform application.

For example, you can decrease the default synchronization frequency to limit battery consumption and network usage.
Before you begin:
  1. Create a branch in your application so that you can later add the file that contains the JavaScript code to your application.

    For more information, see Adding development branches to your application.

  2. Specify how you want to customize your app by creating corresponding JavaScript code.

    For more information, see JavaScript APIs for offline-enabled mobile apps.

    Creating a text file that holds the JavaScript code

  1. In the header of Dev Studio, click CreateTechnicalText File.
  2. On the Create Text File tab, in the Text File Record Configuration section, configure the text file:
    1. In the Label field, enter a name for the text file.
    2. In the App Name (Directory) field, enter webwb.
    3. In the File Type (extension) field, enter js.
  3. In the Context section, specify the branch and ruleset for the file.
  4. Click Create and open.
  5. Adding the JavaScript code to the text file

  6. On the Main tab, in the text field, enter the JavaScript code that you want to include in your application.
  7. In the upper-right corner of the screen, click Save.
  8. Adding the text file to your application

  9. In the navigation pane of Dev Studio, click Records.
  10. Expand the Technical category and click Static Content Bundle.
  11. In the Bundle Name column, open the configuration tab for the rule by clicking pypega_ui_userscripts_offline.
  12. On the Definition tab, click the Add item icon.
  13. In the added row, add the JavaScript code to the UI rule:
    1. In the App name field, enter webwb.
    2. In the File extension field, enter js.
    3. In the File name field, enter the name of the text file that contains the JavaScript code.
  14. Check out the pypega_ui_userscripts_offline rule to your development branch:
    1. Click the arrow next to the Private edit button, and then select Check out to branch.
    2. In the Check Out to Branch dialog box, in the Branch menu, select the branch that you created.
    3. Click Check out to branch.
  15. In the upper-right corner of the screen, click Save.
What to do next: Merge the branch that contains the checked-out pypega_ui_userscripts_offline into the target ruleset of your application. For more information, see Merging branches into target rulesets.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us