Skip to content

Latest commit

 

History

History
434 lines (353 loc) · 10.4 KB

File metadata and controls

434 lines (353 loc) · 10.4 KB
title Snippet Title
description Brief description of what this snippet does and when to use it
category XX-category-name/subcategory
tags
tag1
tag2
tag3
primary-functionality
difficulty beginner
prerequisites
Basic Power Fx knowledge
Specific connector or feature
author YourGitHubUsername
created 2024-11-17
updated 2024-11-17
featured false
related
path/to/related/snippet1
path/to/related/snippet2

Snippet Title

Table of Contents

{Brief description - should match the YAML description above}

🎯 What This Snippet Does

{Detailed explanation of the snippet's purpose and functionality. Include:

  • What problem it solves
  • When to use it
  • Key benefits
  • Any limitations}

📋 Prerequisites

Before using this snippet, ensure you have:

  • {Prerequisite 1}: {Explanation why it's needed}
  • {Prerequisite 2}: {Explanation why it's needed}
  • {Power Apps Version}: {Minimum version required}

🛠️ Implementation

Step-by-Step Setup

  1. {Step 1}: {Detailed instructions}

    // Code for step 1
    Set(variableName, "value");
    
  2. {Step 2}: {Detailed instructions}

    // Code for step 2
    Set(anotherVariable, variableName * 2);
    
  3. {Step 3}: {Detailed instructions}

    // Code for step 3
    Navigate(Screen2, ScreenTransition.Fade);
    

Complete Code

/* ===========================================================================================

    {Snippet Title}
    {Brief description}

    Author: {Your Name}
    Created: {Date}
    Updated: {Date}

    Parameters:
        {param1} ({type}): {description}
        {param2} ({type}): {description}

    Returns:
        {returnType}: {description}

    Example:
        {functionName}({param1}, {param2})

    ===========================================================================*/

// Main implementation
Set(
    result,
    // Your Power Fx code here
    "Hello, World!"
);

// Additional logic
If(
    !IsBlank(result),
    Notify("Success: " & result, NotificationType.Success),
    Notify("Error: Operation failed", NotificationType.Error)
);

🎨 YAML Configuration

If this snippet requires specific control configurations, include them here:

# Screen or component configuration
- ControlName:
    Control: Classic/Button
    Properties:
      Text: ="Click Me"
      OnSelect: |
        =Set(result, "Button clicked!")
      X: =100
      Y: =100
      Width: =200
      Height: =50

📖 Usage Examples

Basic Example

// Simple usage
Set(simpleResult, SnippetFunction("basic input"));

Advanced Example

// Complex usage with error handling
Set(
    advancedResult,
    If(
        IsBlank(inputValue),
        Notify("Input is required", NotificationType.Warning),
        SnippetFunction(inputValue)
    )
);

Real-World Scenario

// Production-ready implementation
Try(
    Set(
        productionResult,
        SnippetFunction(
            validatedInput,
            optionalParameter
        )
    ),
    Notify("Operation completed successfully", NotificationType.Success)
);

🔧 Customization Options

Parameter Variations

Parameter Type Default Description
input Text "" Primary input value
options Record {} Configuration options
callback Function Blank() Optional callback function

Configuration Settings

// Default configuration
Set(
    config,
    {
        theme: "light",
        language: "en",
        debug: false
    }
);

// Custom configuration
Set(
    customConfig,
    UpdateContext(
        config,
        {
            theme: "dark",
            debug: true
        }
    )
);

🐛 Troubleshooting

Common Issues

Issue: {Error message or problem}

Symptoms: {What the user sees} Cause: {Why this happens} Solution:

// Corrected code
Set(fixedVariable, ProperFix());

Issue: {Another common problem}

Symptoms: {What the user sees} Cause: {Why this happens} Solution:

// Alternative approach
Set(alternativeResult, DifferentApproach());

Debug Tips

// Add debug logging
Set(
    debugInfo,
    {
        timestamp: Now(),
        input: inputValue,
        result: result,
        error: IfError("No error", FirstError.Message)
    }
);

// Display debug information
Notify(
    "Debug: " & JSON(debugInfo, JSONFormat.Indented),
    NotificationType.Information
);

🚀 Performance Considerations

Optimization Tips

  1. {Tip 1}: {Explanation and code example}

    // Optimized version
    Set(optimizedResult, CachedCalculation());
    
  2. {Tip 2}: {Explanation and code example}

    // Memory-efficient approach
    ClearCollect(tempCollection, Filter(source, condition));
    

Performance Benchmarks

Scenario Before After Improvement
{Scenario 1} {X}ms {Y}ms {Z}% faster
{Scenario 2} {A} operations {B} operations {C}% reduction

🔒 Security Best Practices

Input Validation

// Validate user input
Set(
    validatedInput,
    If(
        IsMatch(inputValue, "^[A-Za-z0-9 ]+$"),
        inputValue,
        Notify("Invalid input format", NotificationType.Error)
    )
);

Data Protection

// Sanitize sensitive data
Set(
    safeData,
    Substitute(
        sensitiveData,
        "[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}",
        "****-****-****-****"
    )
);

🧪 Testing

Unit Tests

// Test cases
ClearCollect(
    testCases,
    {
        input: "valid input",
        expected: "expected output",
        description: "Test case description"
    },
    {
        input: "edge case",
        expected: "edge output",
        description: "Edge case test"
    }
);

// Run tests
ForAll(
    testCases,
    If(
        SnippetFunction(input) = expected,
        Notify("✅ " & description & " passed", NotificationType.Success),
        Notify("❌ " & description & " failed", NotificationType.Error)
    )
);

Integration Testing

// End-to-end test
Set(
    integrationTest,
    {
        setup: /* Setup code */,
        execution: /* Main execution */,
        validation: /* Result validation */,
        cleanup: /* Cleanup code */
    }
);

📚 Related Snippets

Complementary Functionality

  • {Related Snippet} (TODO: update link) - {How it complements this snippet}
  • {Another Related} (TODO: update link) - {Additional relationship}

Alternative Approaches

  • {Alternative Method} (TODO: update link) - {When to use this instead}
  • {Different Solution} (TODO: update link) - {Alternative for different scenarios}

Advanced Extensions

  • {Extended Version} (TODO: update link) - {More advanced implementation}
  • {Specialized Variant} (TODO: update link) - {For specific use cases}

🔗 External Resources

Official Documentation

  • Microsoft Learn: {Topic} (TODO: update link)
  • Power Apps Documentation (TODO: update link)

Community Resources

  • Power Platform Community Thread (TODO: update link)
  • YouTube Tutorial (TODO: update link)
  • Blog Post (TODO: update link)

Related Tools

  • {Tool Name} (TODO: update link) - {Tool description}
  • {Another Tool} (TODO: update link) - {Tool description}

🤝 Contributing

Improvements

This snippet can be enhanced by:

  • Adding support for {new feature}
  • Improving error handling for {edge case}
  • Adding performance optimizations for {scenario}

Reporting Issues

Found a bug or have a suggestion? Create an issue (TODO: update link) with the "bug" or "enhancement" label.

Code Reviews

All contributions are welcome! Please ensure:

  • Code follows the style guide (TODO: update link)
  • Tests are included for new functionality
  • Documentation is updated accordingly

📊 Version History

Version Date Changes
1.0.0 2024-11-17 Initial release
1.1.0 2024-XX-XX {Planned improvements}

📝 License

This code snippet is provided as-is under the MIT License (TODO: update link).

History

Date Author Changes
2026-01-27 Migration Initial TOC and history section added