Showing results for 
Search instead for 
Did you mean: 
Helper V
Helper V

Text Input Default Function and Checkboxes for Collecting (Please Help, im desperate)



I have an app where the user collects sample points i have it so the user can quickly put in some text in a text input field (ill call TEXTINPUT1) on a canvas app the type of text has the following format ZZ123456 and can be between ZZ000001 and ZZ999999 i have some simple background code with hidden labels so if the user uses the text and numbers ZZ999001 the next one added to TEXTINPUT1 field is ZZ999002 its so the user doesnt have to enter each sampleID manually and avoids mistakes in data. The user presses on a add button which collects and displays the data in a gallery for the user to patch it later to sharepoint.


My problem is the users now want to be able to have many empty sample numbers at the start of project and many empty sampleID anywhere before they patch (they want to save on sampling costs and know which points they want to sample and which ones they dont)


My first idea was to add a checkbox that says turn off sample id accuring,


However i cannot figure out the code to make it work.


Here is an example of what im trying to do.




i need the Textinput field to be blank until the user wishes to add a sample ID to the collection/gallery and the numbers accrue in the TEXTINPUT1 field, which i can achieve by the following two bits of code



If(IsEmpty(Gallery1.AllItems),"", NextSampleID.Text)


And the following collect is a onsubmit on a button

Collect(colTEST, {Title:"Title", 
SampleID:If(CHECKBOX1.Value = true, TEXTINPUT1.Text, "")})


However now when i turn the checkbox off the default value of the code becomes ZZ000001 because of the default code which looks at the hidden labels in the background to determine the next sample id name in the sequence (Its a few bits of string code to extract the numbers seperately and +1 and concat the text and numbers back together and that is the label called NextSampleID.Text


So i have two problems and no solutions i have come up with have worked, so If the user wants to turn the checkbox on in the middle of some sampling he will have to remove the ZZ000001 and manually reenter the next sampleID (bad it will lead to bad inputted user error data) and that also at the start of the app when the user will have many empty sample points the user will have to again remove the default ZZ000001 on the hidden labe; NextsampleID (Also bad because if its not blank they will forget and ill have to manually change it)


Could someone please help, ive been at this for weeks and its due tomorrow and i look incompetent.


Its got to the stage im thinking of calling in sick..


Impactful Individual
Impactful Individual

have you tried creating a hidden timer that every (x) milliseconds expires and OnEnd parses your gallery for the newest item, and then generates the default value for storage (then if they turn it on mid work cycle the default value will have been keeping itself updated this entire time). You can set the timer to half a second or less, then on its expiration have it autorenew so this goes on as long as the app is open.

Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (66,889)