web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to set account status (Active or inactive) based on number of invoices in a set period of time?

(0) ShareShare
ReportReport
Posted on by 155

Hi,

I want to be able to segregate my accounts based on their activity. If an active account has less than 5 invoices in 6 months, I want its status to change to Inactive. Check should happen every month.

Thank you!

Patrick 

I have the same question (0)
  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    Hi,

    You can create Schedule flow to run every month.

    docs.microsoft.com/.../run-scheduled-tasks

    then use List rows to fetch active accounts. Loop through each account and fetch related invoices created in last 6 months using fetch xml which are associated to account

    - then check count of invoices by using conditions

    - If count<5 deactivate account else do nothing

    CR36.PNG

    CR37.PNGCR38.PNG

    CR39.PNGCR40.PNG

    Condition -> 

    length(body('List_rows_2')?['value'])

    Get Count of List rows - 

    https://d365demystified.com/2020/05/20/get-count-of-records-retrieved-in-cds-connector-in-a-flow-power-automate/

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Patrick Mandengue Profile Picture
    155 on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    Thank again! I am still working on it and I would like ot know what is the actual full expression in the last condition: Fx Length(....)?

    length ('Value') from previous output?

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    HI,

    Please see below the expression I used to check count of records -

    length(body('List_rows_2')?['value'])

    List_rows_2 -> My List Row action name so if you are renaming this to something else then you will need to update the formula as well.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Patrick Mandengue Profile Picture
    155 on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    Error-Message.png

    Please can you help here. where can I find the settings to configure the buffer please. I have more than 10,000 lines in my Account table to run everyday to check the status based on their activity.

    Thanks.

    Patrick 

  • Verified answer
    Amit Katariya007 Profile Picture
    10,409 Super User 2025 Season 2 on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    Hello Patrick,

    You can use the Pagination where u can override the default fetch record count. Please refer article to update the pagination.

    powerusers.microsoft.com/.../1258148

    Thank you,

    Amit katariya

  • Patrick Mandengue Profile Picture
    155 on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    I still a weird error message. Please can you help?

    pastedimage1649857520913v1.png

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    Hi,

    Can you please share list rows filter rows property value ?

    I think you are missing paranthesis or you are having extra paranthesis.

    _customerid_value try this.

    You can use Fetch XML builder in xrmtoolbox to generate the query.

    Thanks,

    Bipin

  • Patrick Mandengue Profile Picture
    155 on at
    RE: How to set account status (Active or inactive) based on number of invoices in a set period of time?

    This is the error message:   ')' or operator expected at position 13 in '( customerid value eq 8edd6738-d8c9-eb11-bacc-000d3a231383 and Microsoft.Dynamics.CRM.LastXMonths(PropertyName='createdon',PropertyValue=6))'.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 113 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 104

#3
#ManoVerse Profile Picture

#ManoVerse 56

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans