web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Limit Max Length on Si...
Power Apps
Unanswered

Limit Max Length on Single Text Field upon Condition

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I have formula below but it's not working as per stated condition if blank = Parent. Error, RQ- 11 max length and OP-13 max length. 

Coalesce( Parent .Error,If(!IsBlank(DataCardValue14.Text)&&Len(StartsWith(DataCardValue14.Text, "OP"))<13 Or Len(StartsWith(DataCardValue14.Text, "OP"))>13,"The number of characters should be 13",Len(StartsWith(DataCardValue14.Text, "RQ"))<11 Or Len(StartsWith(DataCardValue14.Text, "RQ"))>11,"The number of characters should be 11"))

 

 

Thanks for the help!!

Categories:
I have the same question (0)
  • sgtsnacks64 Profile Picture
    322 Super User 2024 Season 1 on at

    Hey @shine_d 

    Not entirely sure what your code is actually meant to be checking. But your issue might be around using Len() to check StartsWith(), which returns a boolean (true or false) value.

     

    EndsWith and StartsWith functions - Power Platform | Microsoft Learn

    Potentially changing Len(StartsWith()) to Find() might do what you're expecting, as Find() will return the position the string is found.

     

    If you're trying to set the maximum length, you can do this on a text field, providing your code outputs the integer value to limit the field by.

    Find function - Power Platform | Microsoft Learn


    Coalesce( 
    	Parent.Error,
    	If(
    		!IsBlank(DataCardValue14.Text)
    		&& Find(DataCardValue14.Text, "OP")<13 
    		Or Find(DataCardValue14.Text, "OP")>13,
    	"The number of characters should be 13",
    	Find(DataCardValue14.Text, "RQ")<11 
    	Or Find(DataCardValue14.Text, "RQ")>11,"The number of characters should be 11"))
  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @shine_d ,

    I can't figure it out what is your objective, but seems that you don't use correctly the StartsWith() operator. This operator return a bool value (true, false) and not the DataCardValue.Text (used inside operator). 

    Here is my proposal:

     

    Coalesce(
     Parent.Error,
     Switch(
     Left(DataCardValue14.Text,2),
     "OP",
     If( Len(DataCardValue14.Text<>13, "The number of characters should be 13"),
     "RQ"
     If( Len(DataCardValue14.Text<>11, "The number of characters should be 11"),
     "Your value need to start with OP / RQ"
    )
    

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard