Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Add date, time, second and incremental "+1" to each filename.

Posted on by 361

i am a beginner with formulas.

I have this code below:

 

Set(
 varSuccess;
 Blank()
);;
Clear(colFinalData);;
ForAll(
 galMetadata.AllItems;
 Collect(
 colFinalData;
 {
 Title: txtTitle.Text;
 Name: lblNameVal.Text;
 DataStream: imgDataStream.Image
 }
 )
);;
Set(
 varSuccess;
 'PowerApps-SendFilesWithMetadataToSharePoint'.Run(
 JSON(
 colFinalData;
 JSONFormat.IncludeBinaryData
 )
 ).success
);;
If(
 varSuccess="Yes";
 Clear(colFiles);;
 Notify(
 "Your files have been successfully upload to the data source";
 NotificationType.Success;
 3000
 );;
 Refresh(ListData);;
 Navigate(
 'Home Screen';
 ScreenTransition.CoverRight
 );
 Notify(
 "Error uploading files. Please try again or contact administrator";
 NotificationType.Error;
 3000
 )
)

 

 

i need to add the date,time,seconds and incremental "+1" to each filename "Title: txtTitle.Text;" please help me to rectify this formula. Thank you.

  • Sormick Profile Picture
    Sormick 361 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    I have a error after:

    ForAll(
    galMetadata.AllItems;
    Collect(
    colFinalData;
    {
    Title: txtTitle.Text;
    Name: lblNameVal.Text;
    DataStream: imgDataStream.Image
    }
    )
    );;

    This code gives me an error:

    UpdateContext( varIncrement; varIncrement + 1 );;

    Error message:

    number of invalid arguments. 2 were received one was expected

     

  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    Try this 

     

    Clear(colFinalData); 
    Set(varIncrement;1);
    ForAll( galMetadata.AllItems;
    Collect(
    colFinalData;
    {
    Title: txtTitle.Text & "_" & Text(Now(); "ddmmyyyyhhmmss") & "_" & Text(Second(Now()); "00") & "_" & varIncrement;
    Name: lblNameVal.Text;
    DataStream: imgDataStream.Image }
    ) );
    UpdateContext( varIncrement; varIncrement + 1 );
    Set( varSuccess;
    'PowerApps-SendFilesWithMetadataToSharePoint'.Run( JSON( colFinalData; JSONFormat.IncludeBinaryData ) ).success );
    If(
    varSuccess="Yes";
    Clear(colFiles);
    Notify( "Your files have been successfully uploaded to the data source"; NotificationType.Success; 3000 );
    Refresh(ListData); Navigate( 'Home Screen-2'; ScreenTransition.CoverRight ) );
    Notify( "Error uploading files. Please try again or contact administrator";
    NotificationType.Error; 3000
    )
  • Sormick Profile Picture
    Sormick 361 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    Hi Rajkumar_404, your formula above gives me an error: only with this: 

    Set(
    varIncrement;
    varIncrement + 1
    )

     If a remove this i get no error but by increment value dans not work. Please find the formula without errors but also without the varincrement

     

    Set(
    varSuccess;
    Blank()
    );;
    Clear(colFinalData);;
    Set(varIncrement;1);;
    ForAll(
    galMetadata.AllItems;
    Collect(
    colFinalData;
    {
    Title: txtTitle.Text & "_" & Text(Now(); "ddmmyyyyhhmmss") & "_" & Text(Second(Now()); "00") & "_" & varIncrement;
    Name: lblNameVal.Text;
    DataStream: imgDataStream.Image
    }
    )
    );;

    Set(
    varSuccess;
    'PowerApps-SendFilesWithMetadataToSharePoint'.Run(
    JSON(
    colFinalData;
    JSONFormat.IncludeBinaryData
    )
    ).success
    );;
    If(
    varSuccess="Yes";
    Clear(colFiles);;
    Notify(
    "Your files have been successfully upload to the data source";
    NotificationType.Success;
    3000
    );;
    Refresh(ListData);;
    Navigate(
    'Home Screen-2';
    ScreenTransition.CoverRight
    );
    Notify(
    "Error uploading files. Please try again or contact administrator";
    NotificationType.Error;
    3000
    )
    )

     

     

    Please help me to add the encrement code without causing errors

  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    You can use ; (Semi-Colon) instead of , comma.

     

    Set(varIncrement; varIncrement + 1); 
  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    Currently, there is no specific tool to directly translate Power Fx formulas from English to French within Power Apps. However, you can use the Microsoft Translator connector in Power Apps to translate text on demand.

     

    Refer this link :  Connect to Microsoft Translator from Power Apps - Power Apps | Microsoft Learn

    Language function - Power Platform | Microsoft Learn

     

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • Sormick Profile Picture
    Sormick 361 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    May i also ask you if there is a tool to translate power Fx formulas from English to French?

  • Sormick Profile Picture
    Sormick 361 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    Unfortunately i'm using a french version of Power apps and the french formulas are slightly different from english.

    When i copy-Paste the formulas above it gives me multiple errors. It seems that formulas like set formulas below.

    But i don't know what ar other changes , so i'm stuck at the moment.

    Set(varIncrement, varIncrement + 1); 

    should be instead
    Set(varIncrement, varIncrement + 1);; 
    Set(varIncrement;

     

  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    @Sormick Try this formula too,

     

    You can use the "mmddyyyyhhmmss" format to get the current date and time in the format MM-DD-YYYY-HH-MM-SS.

     

    Set(
    varSuccess;
    Blank()
    );;
    Clear(colFinalData);;
    Set(
    varIncrement;
    1
    );;
    ForAll(
    galMetadata.AllItems;
    Collect(
    colFinalData;
    {
    Title: txtTitle.Text & "_" & Text(Now(); "mmddyyyyhhmmss") & "_" & Text(Second(Now()); "00") & "_" & varIncrement;
    Name: lblNameVal.Text;
    DataStream: imgDataStream.Image
    }
    );
    Set(
    varIncrement;
    varIncrement + 1
    )
    );;
    Set(
    varSuccess;
    'PowerApps-SendFilesWithMetadataToSharePoint'.Run(
    JSON(
    colFinalData;
    JSONFormat.IncludeBinaryData
    )
    ).success
    );;
    If(
    varSuccess="Yes";
    Clear(colFiles);;
    Notify(
    "Your files have been successfully upload to the data source";
    NotificationType.Success;
    3000
    );;
    Refresh(ListData);;
    Navigate(
    'Home Screen';
    ScreenTransition.CoverRight
    );
    Notify(
    "Error uploading files. Please try again or contact administrator";
    NotificationType.Error;
    3000
    )
    )

     

     

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

  • Rajkumar_404 Profile Picture
    Rajkumar_404 6 on at
    Re: Add date, time, second and incremental "+1" to each filename.

    Hi @Sormick 

     

    First, initialize your increment variable outside of your ForAll loop in App OnStart or Screen OnVisiable

     

    Set(varIncrement, 0);

    Then, inside your ForAll loop, increment the variable and add it to your title:

     

    ForAll( 
    galMetadata.AllItems;
    Set(varIncrement, varIncrement + 1);
    Collect( colFinalData;
    {
    Title: txtTitle.Text & Text(Now(), "[$-en-US] mm/dd/yyyy hh:mm:ss") & varIncrement;
    Name: lblNameVal.Text;
    DataStream: imgDataStream.Image }
    )
    );

     

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard