cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Sifu
Level: Powered On

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
mdevaney
Level 8

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
mdevaney
Level 8

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

Sifu
Level: Powered On

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)
mdevaney
Level 8

Re: Making fields required while using Collect

@Sifu 

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

Sifu
Level: Powered On

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

mdevaney
Level 8

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)
Sifu
Level: Powered On

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)

 

mdevaney
Level 8

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 291 members 5,311 guests
Please welcome our newest community members: