Advanced Portal Designer Documentation
Index

Working with Branches

This page explains how to use GitHub branches to manage different environments like sandbox and production.

Why Use Branches?

Branches allow you to:

  • Maintain separate configurations for each environment
  • Develop and test safely before production deployment
  • Roll back to previous states if needed
  • Collaborate without affecting live portals

Branch Strategy

Branch Purpose Environment
main Production-ready configuration Production BC
develop Active development Sandbox BC
feature/* Specific features Local/Sandbox

Branch Flow

┌─────────────────────────────────────────────────────────────────────────┐
│                         Branch Workflow                                  │
└─────────────────────────────────────────────────────────────────────────┘

  ┌──────────┐                                           ┌──────────────┐
  │ Sandbox  │──── Commit ────►  develop  ─── Merge ───► │     main     │
  │   BC     │                                           │   (GitHub)   │
  └──────────┘                                           └──────────────┘
                                                                │
                                                                │ Pull
                                                                ▼
                                                         ┌──────────────┐
                                                         │  Production  │
                                                         │     BC       │
                                                         └──────────────┘

Setting Up Multiple Branches

Create Branches in GitHub

  1. Go to your repository on GitHub
  2. Click the branch dropdown (shows current branch name)
  3. Type a new branch name (e.g., develop)
  4. Click Create branch: develop from main

Configure Each Environment

Sandbox Environment:

  1. Open the Advanced Portal Designer menu page and click Setup
  2. Set GitHub Branch to develop
  3. Commit and pull work in progress

Production Environment:

  1. Open the Advanced Portal Designer menu page and click Setup
  2. Set GitHub Branch to main
  3. Only pull approved changes

Typical Workflow

Development Phase

  1. Work in sandbox Business Central
  2. Create/modify actions, templates, content
  3. Test thoroughly in sandbox
  4. Commit to GitHub (pushes to develop branch)

Review Phase

  1. Go to GitHub repository
  2. Create a Pull Request from develop to main
  3. Review the changes
  4. (Optional) Have team member approve

Deployment Phase

  1. Merge the Pull Request in GitHub
  2. Open production Business Central
  3. Pull from GitHub (pulls from main branch)
  4. Verify portal works correctly

Switching Branches

Change Branch in APD

To switch which branch APD uses:

  1. Open the Advanced Portal Designer menu page and click Setup
  2. Change the GitHub Branch field
  3. Save the change

Warning: After switching branches, pull to synchronize with that branch.

Example: Check Production State

To see production configuration in sandbox:

  1. Change branch to main
  2. Pull from GitHub
  3. Review the configuration
  4. Change back to develop when done
  5. Pull to restore development state

Merging Branches

Using GitHub Web Interface

  1. Go to your repository
  2. Click Pull requests → New pull request
  3. Set base: main and compare: develop
  4. Review the changes
  5. Click Create pull request
  6. Add description of changes
  7. Click Merge pull request

Using GitHub Desktop

  1. Open GitHub Desktop
  2. Switch to main branch
  3. Click Branch → Merge into current branch
  4. Select develop
  5. Click Create a merge commit
  6. Push to GitHub

Handling Conflicts

What Causes Conflicts?

Conflicts occur when:

  • Same file changed in both branches
  • Changes to same action in different environments
  • Templates modified in multiple places

Resolving Conflicts

  1. Open the Pull Request in GitHub
  2. Click Resolve conflicts
  3. Review the conflicting files
  4. Choose which version to keep (or combine)
  5. Mark as resolved
  6. Complete the merge

Preventing Conflicts

Best practices to avoid conflicts:

  • Make all changes in sandbox first
  • Never modify production directly
  • Commit frequently
  • Communicate with team members

Advanced: Feature Branches

For larger changes, use feature branches:

Create Feature Branch

  1. In GitHub, create branch feature/new-dashboard from develop
  2. In sandbox, switch to feature/new-dashboard
  3. Develop the new feature
  4. Commit regularly

Merge Feature Branch

  1. Create Pull Request: feature/new-dashboard → develop
  2. Review and test
  3. Merge to develop
  4. Delete the feature branch

Environment Mapping

Simple Setup (2 Environments)

Environment Branch
Sandbox develop
Production main

Complex Setup (Multiple)

Environment Branch
Development develop
QA/Testing qa
Staging staging
Production main

Per-Customer Portals

Customer Branch
Contoso Production main
Contoso Sandbox develop
Fabrikam Production fabrikam-main
Fabrikam Sandbox fabrikam-dev

Rollback Procedures

Revert a Merge

If a deployment causes issues:

  1. In GitHub, go to the merge commit
  2. Click Revert to create a revert commit
  3. Pull in production to apply the revert

Restore from Previous Commit

  1. Find the last known good commit in GitHub
  2. Create a new branch from that commit
  3. Merge that branch to main
  4. Pull in production

Manual Rollback

  1. In sandbox, switch to main branch
  2. Pull the current production state
  3. Make necessary fixes
  4. Commit back to develop
  5. Go through normal merge process

Best Practices

Commit Messages

Use clear descriptions in your external tracking:

✅ Good:
- Added customer dashboard with orders
- Fixed security profile for vendors
- Updated header template with new logo

❌ Avoid:
- Updates
- Fixed stuff
- Changes

Branch Hygiene

  • Delete merged feature branches
  • Keep develop and main clean
  • Regularly merge main back to develop to stay current

Testing Checklist

Before merging to production:

  • All actions compile successfully
  • Templates render correctly
  • Forms work as expected
  • Security restrictions apply properly
  • Content displays correctly