#PowerPlatformTip 82: 'Automated Code Commenting'
TL;DR: Let ChatGPT add clear comments to your Power Apps formulas, paste the formula, ask it to comment without changing the code, then review and apply.
💡 Challenge
Writing code comments in your Power Apps formula can be time-consuming and sometimes overlooked, yet it’s crucial for maintainability and collaboration.
✅ Solution
Leverage AI with ChatGPT to automatically generate detailed comments for your Power Apps formulas.
🔧 How It’s Done
Here’s how to do it:
- Prepare your formula
🔸 Ensure your Power Apps formula is ready for commenting. -
Use ChatGPT
🔸 Input your formula into a ChatGPT-enabled platform.🔸 Use this prompt: “Please add code comments to my Power Apps formula, but keep the code as it is.”
-
Review and implement
🔸 Review generated comments for accuracy.🔸 Incorporate the comments into your Power Apps formula.
🎉 Result
You’ll have a well-commented Power Apps formula that is easier to understand, maintain, and collaborate on.
🌟 Key Advantages
🔸 Efficiency: Save time by automating the commenting process.
🔸 Clarity: AI-generated comments can provide insights you might have missed.
🔸 Collaboration: Well-commented code is easier for team members to understand and work on.
🎥 Video Tutorial
🛠️ FAQ
1. Which AI model should I use for code comments?
Use a model that can read Power Fx formulas, then check every comment against the formula before adding it to the app.
2. How do I ensure the generated comments accurately reflect my logic?
Always review and validate AI-generated comments before implementation to confirm they match your formula’s intent.
3. Can I automate commenting for multiple formulas at once?
Yes, you can batch multiple formulas in one request to ChatGPT to streamline the process, but monitor response size and clarity.
🔗 Related Tips
🔸 #PowerPlatformTip 65: ‘Automate Documentation with PowerDocu’ - generate full app and flow documentation once your formulas are commented.
🔸 #PowerPlatformTip 116: ‘AI Automated Solution Design’ - use AI earlier in the process, to draft the solution design itself.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).