This repository contains a Power Apps Component Framework (PCF) control named AutoSplitTextControl, designed for Dynamics 365 CRM or Dataverse environments. The control provides two text areas: a primary field (field1) with a user-configurable maximum length and an overflow field (field2) with a fixed 4000-character limit. When field1 reaches its maximum length, excess text automatically overflows to field2, which is saved to a Dataverse field specified by targetFieldLogicalName.
- Provides a reusable PCF control to split text input across two single-line text fields in Dynamics 365, with dynamic length limits and seamless Dataverse integration.
- Configurable maximum length for
field1via themaxLengthproperty (capped at 4000 characters). - Automatic overflow of excess text from
field1tofield2(supports up to 4000 characters). - Real-time character counters for both fields (e.g.,
150/1000forfield1,50/4000forfield2). - Visual feedback with a red border on
field1when the maximum length is reached. - Consistent styling using Segoe UI, Arial, sans-serif fonts.
- Integration with Dataverse:
field1andfield2bind toSingleLine.Textfields, withfield2data saved to a field specified bytargetFieldLogicalName. - Prevents errors like "You have exceeded the maximum number of 100 characters" by enforcing field length limits.
- TypeScript for control logic.
- CSS for styling.
- Power Apps CLI for development and deployment.
-
Node.js: Version 14.x or later (install via nodejs.org).
-
Power Apps CLI: Install using
npm install -g @microsoft/powerapps-cli
pac auth create
-
Visual Studio Code or another code editor (recommended).
-
Dataverse Environment: Access to a Dynamics 365 CRM or Power Apps environment with System Administrator or System Customizer permissions.
-
Dataverse Fields: Two
SingleLine.Textfields with a maximum length of 4000 characters (e.g.,new_primarytext,new_overflowtext).
git clone https://github.com/yourusername/AutoSplitTextControl.git
cd AutoSplitTextControlnpm installRun the following command to set up the solution with your publisher details:
pac solution init --publisher-name "AutoSplitTextDev" --publisher-prefix autosplitAdd the PCF project reference:
pac solution add-reference --path .msbuild /t:restore
msbuildThis generates a .zip file (e.g., AutoSplitTextControl_0_0_1_0.zip) in the bin/debug folder.
Use the Power Apps CLI to import the solution into your Dataverse environment:
pac solution import --path bin\debug\AutoSplitTextControl_0_0_1_0.zip --environment <EnvironmentIdOrName>Replace <EnvironmentIdOrName> with your environment ID (find it with pac env list).
Alternatively, import via the Power Apps Maker Portal:
- Go to https://make.powerapps.com
- Select your environment.
- Use Solutions > Import solution.
pac solution publishOr publish manually in the Maker Portal after importing.
- Open a model-driven app form in the Power Apps Maker Portal.
- Select a
SingleLine.Textfield (e.g.,new_overflowtext), go to Properties, and click Add Control. - Choose AutoSplitTextControl (e.g.,
autosplit_AutoSplitTextControl).
- Bind
field1tonew_primarytext. - Bind
field2tonew_overflowtext. - Set
targetFieldLogicalNametonew_overflowtext. - Set
maxLengthto the desired limit forfield1(e.g., 1000). - Save and publish the form.
- Primary Text (
field1): Enter text up to the configuredmaxLength(e.g., 1000 characters). A character counter shows usage (e.g.,150/1000). - Overflow Text (
field2): Excess text fromfield1automatically moves tofield2, which supports up to 4000 characters. A counter shows usage (e.g.,50/4000). - Visual Feedback: A red border appears on
field1when it reaches its limit, and focus shifts tofield2. - Saving Data:
field1saves tonew_primarytext, andfield2saves to the field specified bytargetFieldLogicalName(e.g.,new_overflowtext).
Compatible with modern browsers (e.g., Chrome, Edge, Firefox) used in Dynamics 365.
Run locally with:
npm run startOpen the provided URL (e.g., http://localhost:8181) to test the control.
Check the browser console (F12) for logs to verify:
maxLengthvalue (e.g.,init maxLength: 1000).- Field lengths (e.g.,
getOutputs: { field1: 150, field2: 50, targetFieldLogicalName: "new_overflowtext" }).
- Cause: Dataverse fields (
new_primarytextornew_overflowtext) have a 100-character limit. - Fix: Update fields to 4000 characters in the Power Apps Maker Portal. Verify
targetFieldLogicalNamepoints to a field with a 4000-character limit. - Debug: Check console logs in
getOutputsfor field lengths exceeding 100 characters.
- Cause: Explicit type annotation on
_field2MaxLength. - Fix: Removed in
index.ts(private _field2MaxLength = 4000;).
- Ensure
pac pcf pushcompleted successfully. - Verify form bindings and publish customizations.
- Fork the repository.
- Create a new branch
git checkout -b feature-branch
- Make changes and commit
git commit -m "Describe changes" - Push to the branch
git push origin feature-branch
- Open a pull request.
MIT License - See the LICENSE file for details.
- Author: Advic Tech
- Email: developer@advic.io
- Issues: Report bugs or suggestions on the GitHub Issues page.