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 :
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,985 Moderator on at

    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

    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,985 Moderator on at

    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

    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 Moderator on at

    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

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

    pastedimage1649857520913v1.png

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    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

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
ManoVerse Profile Picture

ManoVerse 127 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans