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 Automate / Function does not work...
Power Automate
Answered

Function does not work as expected

(0) ShareShare
ReportReport
Posted on by 27

Hello.

I have an Apply to each where I get a field from a Sharepoint list and it is used as value for the varAvisoPresentacion variabale. Then I use the following function: 

addToTime(utcNow(), int(variables('varAvisoPresentacion')), 'Day', 'yyyy-MM-dd')

I have checked the varAvisoPresentacion and is always correct (4, 1 and 2 in each iteration). If today is 2023-11-22, instead of getting 2023-11-26, 2023-11-23 and 2023-11-24 I get 2023-11-26, 2024-01-02 and 2025-01-07. 

I heve checked the utcNow in each iteration and is correct, the variable is OK too but the function result is not.

 
Categories:
  • v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @MH15 ,

    Please enter the editing interface and post a screenshot of the configuration of each control in 'flow'. There is no problem with your function, so I need to get more information about your 'flow'.

     

    Best Regards,

    Sunshine Gu

  • MH15 Profile Picture
    27 on at

    Hello  v-yetonggu-msft.

    I paste only the realite about one variable and one branch because the three are the same but with different values in the Sharepoint list.

    MH15_0-1700645511186.png

    MH15_1-1700645548851.png

    MH15_2-1700645578045.png

    MH15_3-1700645592659.png

    MH15_4-1700645627507.png

    MH15_5-1700645808723.png

    MH15_6-1700645845127.png

    MH15_7-1700645865630.png

     

    MH15_8-1700645878589.png

    MH15_9-1700645896057.png

     

     

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    The function addToTime() works great there!

    You append numbers to varAvisoPresentacion each time you loop without resetting the variable, so it keeps getting bigger 😉

    If this behavior is not intended, you shouldn't use a variable there at all!

  • MH15 Profile Picture
    27 on at

    I have checked the value of the variables in each iteration and they are ok.

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    So you have to check again 😉

  • MH15 Profile Picture
    27 on at

    MH15_0-1700651389436.png

    As you can see, the variable is ok but the date should be 2023-11-23.

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    Your screenshot proves nothing ‌‌ 😉

     

    Look at that:

    Chriddle_0-1700652143105.pngChriddle_1-1700652176650.png

     

  • v-yetonggu-msft Profile Picture
    Microsoft Employee on at

    Hi @MH15 ,

    I understand what you mean, but your flow involves sending the same emails repeatedly.

    Would you accept putting items with the same due date in one table and then sending three emails for items with three different due dates?

    You don’t need to use variables. Variables complicate the entire ‘flow’. I have improved your flow to meet your needs.

    Like this:

    vyetonggumsft_5-1700652008467.png

     

    If you accept it, please try to build the flow below.

    First, please go to Classic Designer.

    vyetonggumsft_4-1700651945301.png

    In my scenario:

    vyetonggumsft_6-1700652062055.png

    vyetonggumsft_2-1700651847498.png

     

    addDays(utcNow(),4,'yyyy-MM-dd')
    addDays(utcNow(),1,'yyyy-MM-dd')
    addDays(utcNow(),2,'yyyy-MM-dd')

     

    My SharePoint List:

    vyetonggumsft_7-1700652173217.png

    Best Regards,

    Sunshine Gu

  • Chriddle Profile Picture
    8,729 Super User 2026 Season 2 on at

    "value" is the appended one, not the value of the variable.

  • MH15 Profile Picture
    27 on at

    Hi v-yetonggu-msft.

    For each item in the Sharepoint list I have 3 different dates with 3 different numbers which are the number of days before I need the reminder email. For each case I will send different types of email (3 dates --> 3 types of emails).

    For example:

    ProjectDue dateDue date advise (days)Justification dateJustification date advise (days)Correction dateCorrection date advise (days)
    A25/11/2023330/11/2023815/12/202310
    B30/11/2023830/12/202315  
    C15/09/20231030/10/20231501/12/20239

    In this case, today (22/11/2023) I would get an email type1 por the project A because of Due date, another email type1 for the project B because of Due date, a type2 email for the project A because of the Justification date and a type3 email for the project C because of the Correction date.

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 298 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 289

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard