cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sifu
Continued Contributor
Continued Contributor

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

@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
mdevaney
Super User
Super User

@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."

Sifu
Continued Contributor
Continued Contributor

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)

@Sifu 

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

Sifu
Continued Contributor
Continued Contributor

@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

@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)
Sifu
Continued Contributor
Continued Contributor

@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)

 

@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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,206)