Customising the SurveyJS Editor in CE
The Klevr Portal survey editor can be customized by overriding the klevr_formeditor_customscript.js file.
Customizing the Survey Editor with klevr_formeditor_customscript.js
Overview
The Klevr Portal survey editor can be customized by overriding the klevr_formeditor_customscript.js file. This allows you to extend or modify the default behavior of the survey editor to meet specific business requirements.
Prerequisites
Before customizing the survey editor, ensure you have:
- System Administrator or System Customizer role in Dynamics 365
- Access to the Klevr Portal solution
- Basic knowledge of JavaScript
- Understanding of the Dynamics 365 web resource system
Locating the Custom Script File
The klevr_formeditor_customscript.js file is a web resource within your Dynamics 365 environment. To locate it:
Open your appropriate project solution in the solution explorer.
Search for klevr_formeditor_customscript.js.
If it is not in your solution, add it using the "Add Existing" menu item.
Edit the contents to add your own scripts.
Understanding the Custom Script Structure
The custom script file is injected into the page, right at the end. At this point you can work directly with the Survey object to modify the editor. For instance, to add a custom property on every question, you could use the following code:
Survey.Serializer.addProperty("question", {
name: "CriteriaCounter:boolean", displayName: "Criteria Counter", category: "general", visibleIndex: 6, default: true
});
Best Practices
- Always Test in a Development Environment: Test your customizations thoroughly before deploying to production
- Comment Your Code: Add clear comments explaining your customizations for future maintenance
- Version Control: Keep track of changes using version control or change logs within the file
- Backup Original: Always keep a backup of the original file before making modifications
- Error Handling: Implement proper error handling to prevent the survey editor from breaking
- Performance: Avoid heavy operations in initialization functions to maintain performance
Troubleshooting
Custom Script Not Loading
- Verify the web resource is published
- Clear browser cache and hard refresh (Ctrl + F5)
- Check browser console for JavaScript errors
- Ensure the file name matches exactly:
klevr_formeditor_customscript.js
Customizations Not Applying
- Verify the custom script structure is correct
- Check that function names match the expected callbacks
- Review browser console for errors
- Ensure you're testing in the correct environment
JavaScript Errors
- Open browser Developer Tools (F12)
- Check the Console tab for error messages
- Use
console.log()statements to debug your code - Validate JavaScript syntax using online validators
Additional Resources
- SurveyJS Creator Documentation
- Contact Klevr Apps support for specific customization requests
Support
For assistance with survey editor customization, contact your Klevr Apps implementation partner or reach out to Klevr Apps support.
Last updated on