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 / Deactivating Related R...
Power Apps
Suggested Answer

Deactivating Related Records in Model driven app

(1) ShareShare
ReportReport
Posted on by 10

I have a table called Country and a table called City.

 

City has a lookup to Country, creating the relationship.

 

I want to implement some simple functionality that when the country is deactivated in the model driven app, the related city/cities in the cities table are also deactivated.

For example: if the United Kingdom record is disabled in the Country table. London, Birmingham, Liverpool, etc is disabled in the City table.

 

City table

Country lookup

Liverpool

United Kingdom

London

United Kingdom

Paris

France

Berlin

Germany

 

 

Could someone advise the best approach/way to do this?

 

Kind regards and thanks in advance.

 

 

Categories:
I have the same question (0)
  • Akser Profile Picture
    1,546 Moderator on at

    Hi @JLCrisp,

     

    How do you store the information that a Country is enabled? I guess you have an attribute for that in your Country table (e.g. Active: true/false)?

     

  • JLCrisp Profile Picture
    10 on at

    Hi @Akser,

     

    Thanks for the reply.

    I'm using the standard status code functionality in the model driven app/dataverse table. Where a row is either active or inactive.

     

    JLCrisp_0-1667919031935.png

     

  • Akser Profile Picture
    1,546 Moderator on at

    So is your question, how do I display active countries only? Can't you create a view in Dataverse (where Status = Active) and use that view in your app? 

  • JLCrisp Profile Picture
    10 on at

    Hi @Akser 

     

    I just read my originally post, I didn't finish the sentance (my apologies):

    'I want to implement some simple functionality that when the country is deactivated in the model driven app, the related cities in the cities table are also deactivated.'

     

    So, in summary what I need is some kind of workflow I guess, that when the country in the country table is deactivated (set to inactive), cities records that have the country linked are also deactivated (set to inactive). 

  • JLCrisp Profile Picture
    10 on at

    Hi @Akser 

     

    I just read my original post, I didn't finish the sentence (my apologies):

    'I want to implement some simple functionality that when the country is deactivated in the model driven app, the related cities in the cities table are also deactivated.'

     

    So, in summary what I need is some kind of workflow I guess, that when the country in the country table is deactivated (set to inactive), cities records that have the country linked are also deactivated (set to inactive). 

  • Akser Profile Picture
    1,546 Moderator on at

    I'm confused a little @JLCrisp,

     

    Since you have the status column in your Country table, (based on your relationship) wouldn't the City table look like this?

     

    City tableCountry lookup nameCountry lookup status
    LiverpoolUKInactive
    LondonUKInactive
    ParisFranceActive
    BerlinGermanyActive
  • JLCrisp Profile Picture
    10 on at

    Hi @Akser 

     

    My city table doesn't have the country lookup status, only the status code for the city record. This is a slim down of what my city table is like:

    City Name

    Country Lookup

    City Status code

    London

    United Kingdom

    Active

    Birmingham

    United Kingdom

    Active

    Paris

    France

    InActive

     

    How would I look up to the country status on the country table? The primary column in the country table is 'country name'. The second column looks up to this in the country table (via a lookup data type column). 

  • piergaetano Profile Picture
    148 on at

    hi, is this question solved? I have similar issue

  • Suggested answer
    powerJu Profile Picture
    36 on at
    Easy solution would be creating a Power Automate flow. Trigger - When a row is modified - Selected Columns statecode (it will trigger just when the column Status  is changed) then List row of City with Lookup point to Country and Update them.
     
    Other option would be create an Workflow - Inside Solution - Create New - Automation - Workflow - Select Country table - When Status is changed - Update Record
     
     
  • Suggested answer
    dmb Profile Picture
    12 on at
    Create an automated power automate flow to run from the name of its owner:
    - Trigger: when a row in Country is modified (column statecode).
    - List rows: from City table (filtered by their lookup column to Country, something like _pre_countryid_value eq '@{triggerBody()........' as OData, or you can use fetchXml alternatively. Select only the GUID column as you do not need others.
    - For each loop: for every record found, perform the Update row action (set the state code dynamically to be the same as the Country status coming from the Trigger).
    Ensure the flow owner on Prod has power automate license + highest read/write privileges on the Cities table.
    Consider doing this as a manual flow that accepts the Counry GUID as a param, so you can call it by the Trigger described below, and also from a separate manual/scheduled flow that lists all Countries and for every record calls the main flow. This will be handy to periodically sync the Cities to their Country statis in case some user with privileges change the status of an individual City.
    As this is nomenclature data, it's good idea for the tables to be Organization-owned rather then User/Team owned.
    Also if you plan moving these records to an environment where they do not exist yet, keep in mind that records can initially be created only in Active state, deactivating will need to happen on later stage.

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard