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 / Validate current addre...
Power Apps
Answered

Validate current address using Power Automate

(0) ShareShare
ReportReport
Posted on by 76

I'm building a model driven app which links a person record to multiple contact address records (1:N)

 

However there should only ever be one current address for each person, which is a Yes/No choice field on the Contact record

 

I tried using business rules to enforce this validation but it doesn't seem flexible enough to do this, is it possible to use Power Automate or something else to enforce this kind of validation?

 

It needs to include validation for both changes made from the form and via Excel import

 

Maybe I'm missing something obvious, any help is appreciated

Categories:
I have the same question (0)
  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @Spikyface what does your data looks like? you have a person record which have a current address - i assume that these do not allow duplicate current addresses. Are you then try to see from the other datasources whether mor e than one address exists for a person? 

     
  • AU-22040756-0 Profile Picture
    76 on at

    Hi @rubin_boer 

     

    It's even simpler than that, I only want the user to be able to select a single address as current for a person

     

    The person record has person id, title, forename, surname, membership cost

     

    The contact record has a lookup to the person record Address Line 1, Address Line 2, Town, Zip code and a yes/no field for current address

     

    At the moment, there's nothing stopping a user from creating 3 contact records which are related to the same person and marking the current address field as Yes for all of them (which makes no sense, how can a person have 3 current addresses?!)

  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @Spikyface ok lets see if i get you. i assume the lookup is done by person id. based on your last paragraph your problem is as such:

     

    Button OnSelect

    ClearCollect(_Person,{person_id:0 ,title: "Mr", forename: "Jack", surname:"Black", membership_cost: 50});

    rubin_boer_0-1614081842927.png

    The user can then add contact, but the problem is they can add it more than once and the yes representing the current address. they can add many

    rubin_boer_1-1614081947929.png

    on the contained will button a check is added to see if the user can add an enntry, iof theuser already have a current address they wont be allowed to add a record.

    Set(_CanUpdate,If(CountRows(Filter(_Contact,And(person_id=0,CurrentAddress = "yes")))=0,true,false));

    If(_CanUpdate, Collect(_Contact,{person_id: 0, AddressLine1:"Here" , AddressLine2: "There", Town: "Some Town", ZipCode: 5555, CurrentAddress: "yes"}));

     

    I hope that help

     
     
  • AU-22040756-0 Profile Picture
    76 on at

    @rubin_boer would that work even on a model driven app?

     

    I've not used any validation like that so far, I thought that kind of functionality was limited to canvas apps

  • rubin_boer Profile Picture
    4,843 Super User 2024 Season 1 on at

    hi @Spikyface  yes it will

  • AU-22040756-0 Profile Picture
    76 on at

    Sorry @rubin_boer I've tried for a long time to wrap my head around where to put this code but I can't figure it out. I know it's example code and I need to take the idea and implement it appropriately in my app but I don't know where to put it or exactly what I'm looking at. Is it an event handler? Is it a custom script I need to reference? Or something else entirely?

     

    Set(_CanUpdate,If(CountRows(Filter(_Contact,And(person_id=0,CurrentAddress = "yes")))=0,true,false));
    
    If(_CanUpdate, Collect(_Contact,{person_id: 0, AddressLine1:"Here" , AddressLine2: "There", Town: "Some Town", ZipCode: 5555, CurrentAddress: "yes"}));

     



    To give you an idea of my level of experience in this area, I'm not even sure which form library to use to add an event handler to a form or control, or how to work out which form library is appropriate (assuming it's even code for an event handler)

     

    Also, if it's on a form or control, it won't prevent validate or prevent changes that are made using Excel import right?



    The form I have looks like this if it's any help, for some reason the Current Address toggle looks a bit strange in the editor but it renders fine when the app is run

    Screenshot 121241.png

     

     



  • Verified answer
    AU-22040756-0 Profile Picture
    76 on at

    In the end I had to use Power Automate for this app and had a flow which triggered on setting the Current Address flag to Yes, it sets Current Address to No for all other address records for that person if they have more than one address

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard