cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Making fields required while using Collect

Hi all,

its pretty simple to make fields required as long as you use standard form, but once i use cascading dropdowns from other souces i must use "Collect"... the formula looks like this:

Collect(
    'Organisational change',
    {
        'Reason for change': reason.Text,
        'Search User': user.Selected,
        'New address of your workplace': work_field.Selected
    }
);
ResetForm(SharePointForm1) && Navigate(Screen1, ScreenTransition.CoverRight)

the problem is that field validation is ignored, i could change the last line from ResetForm to submitform and receive validation but this would still not validate the cascading dropdowns and it would submit the form twice (once with collect and once with submitform code (so without cascading dropdowns...)).

 

any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Making fields required while using Collect

@Sifu 

Yes, of course I can explain.  Sorry if my last post was a bit rushed.

 

Lets say you only want to validate a Text Input field...

 

Not(IsBlank(inputField.Text))

 

... only if a Toggle is set to true...

 

toggle.Value=True

 

...then because we want to check if both conditions are True we put them within the AND function...

 

And(Not(IsBlank(inputField.Text)), toggle.Value=True)

 

...and finally if both conditions are met we want to add to the collection

 

If(
    And(Not(IsBlank(inputField.Text)), toggle.Value=True),
    If(
    validationCheck,
    Collect(
        'Organisational change',
        {
            'Reason for change': reason.Text,
            'Search User': user.Selected,
            'New address of your workplace': work_field.Selected
        }
    )
);

 

Hopefully this all makes sense!

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Making fields required while using Collect

@Sifu 

When using the COLLECT function it will be necessary to write your own validation code.  As an example, here's how I would check if each field is filled before inserting the new record.

 

If(
    And(
        Not(IsBlank(reason.Text)),
        Not(IsBlank(user.Selected)),       
        Not(IsBlank(work_field.Selected))
    ),
    Set(validationCheck,True),
    Set(validationCheck,False)
);
If(
    validationCheck,
    Collect(
        'Organisational change',
        {
            'Reason for change': reason.Text,
            'Search User': user.Selected,
            'New address of your workplace': work_field.Selected
        }
);

I actually don't mind writing my own validation code because I have greater control over the data being inserted.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Resolver I
Resolver I

Re: Making fields required while using Collect

thanks for that one problem i see is that many fields have custom visibility, hence if user chooses one field another might appear... i used below code for "visible properety" as well as for "required property".

 

If(what2change.Selected.Value = "Department and manager", true, false)
Highlighted
Super User
Super User

Re: Making fields required while using Collect

@Sifu 

Are you saying your issue is solved?  If yes, please mark the post as closed.

Highlighted
Resolver I
Resolver I

Re: Making fields required while using Collect

@mdevaney no no, what i mean is that there are for example 6 Fields, but depending on the choice of one of them other fields will appear or hide... so i guess that the controll you suggested would check also the fields that will be hidden, hence the user would not be possible to complete the form

Highlighted
Super User
Super User

Re: Making fields required while using Collect

@Sifu 

My example is only a general example.  The intention was for you to take the concept I showed and adapt it to your own situation.  It is definitely possible to make a validation check conditional on whether specific fields are selected. Check out this code as an example...

 

If(And(Not(IsBlank(inputField.Text)),toggle.Value=True,True,False)
Highlighted
Resolver I
Resolver I

Re: Making fields required while using Collect

@mdevaney can you please explain what i am looking at, sorry but i am quite new to this

If(And(Not(IsBlank(inputField.Text)),toggle.Value=True,True,False)

 

Highlighted
Super User
Super User

Re: Making fields required while using Collect

@Sifu 

Yes, of course I can explain.  Sorry if my last post was a bit rushed.

 

Lets say you only want to validate a Text Input field...

 

Not(IsBlank(inputField.Text))

 

... only if a Toggle is set to true...

 

toggle.Value=True

 

...then because we want to check if both conditions are True we put them within the AND function...

 

And(Not(IsBlank(inputField.Text)), toggle.Value=True)

 

...and finally if both conditions are met we want to add to the collection

 

If(
    And(Not(IsBlank(inputField.Text)), toggle.Value=True),
    If(
    validationCheck,
    Collect(
        'Organisational change',
        {
            'Reason for change': reason.Text,
            'Search User': user.Selected,
            'New address of your workplace': work_field.Selected
        }
    )
);

 

Hopefully this all makes sense!

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,975)