cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
robbo1
Regular Visitor

PowerApp SharePoint Upload Button - Help with formula

Hi guys,

 

I'm pretty new to Power Apps (an enthusiastic amateur!) and I'm having a bit of trouble getting a Flow to communicate with my App. More specifically I'm having trouble writing the formula to get it to work!

 

Using a guide made by Matthew Devaney I've managed to get my app working. However, all I'm now trying to do is add a notification to let the user know the flow has run successfully (or not). I now get an error stating 'Invalid Number of Arguments'. Would someone mind having a look and see if you can work out where I'm going wrong? I've probably missed a bracket or a comma somewhere, but I can't see where and I've run out of articles on Google to look at! 😁 

 

If(ForAll(DataCardValue2.Attachments As Document,'UploadtoSP(2)'.Run({contentBytes:Document.Value,name:Document.Name},ActivityName.Text,ddProductType.Selected.Value,ddUnit.Selected.Result,Text(Act_St_DatePckr.SelectedDate,"[$-en-US]yyyy-mm-dd"),Text(Act_End_DatePckr.SelectedDate,"[$-en-US]yyyy-mm-dd"),dd_Country.Selected.Value,ddPJHQ_JOA.Selected.Value,ddSub_Unit.Selected.'Sub-Unit',CB_Ent_Keywords.Selected.Value,CB_Ent_Keywords_1.Selected.Value,CB_Ent_Keywords_2.Selected.Value).success ="True",Notify("Uploaded successfully.",NotificationType.Success,10000),Notify("Upload failed.",NotificationType.Error,10000)));
 Reset(DataCardValue2);
 Reset(ddProductType);
 Reset(ddUnit);
 Reset(ddSub_Unit);
 Reset(ddPJHQ_JOA);
 Reset(ActivityName);
 Reset(Act_St_DatePckr);
 Reset(Act_End_DatePckr);
 Reset(dd_Country);
 Reset(CB_Ent_Keywords);
 Reset(CB_Ent_Keywords_1);
 Reset(CB_Ent_Keywords_2);

 Flow_1.pngFlow_2.png

Many thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
SebS
Memorable Member
Memorable Member

@robbo1 

 

I'm a donkey 😛

 

You actually need to Wrap it 🙂

 

 

If(
    'Power Automate Flow to Run'.Run().success = "True",
    Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
);

 

 

 

 

 

 

 

 

ForAll(
    DataCardValue2.Attachments As Document,
IF(
    'UploadtoSP(2)'.Run(
       {
        contentBytes: Document.Value,
        name: Document.Name
       },
        ActivityName.Text,
        ddProductType.Selected.Value,
        ddUnit.Selected.Result,
        Text(
	        Act_St_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        Text(
            Act_End_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        dd_Country.Selected.Value,
	    ddPJHQ_JOA.Selected.Value,
        ddSub_Unit.Selected.'Sub-Unit',
        CB_Ent_Keywords.Selected.Value,
        CB_Ent_Keywords_1.Selected.Value,
        CB_Ent_Keywords_2.Selected.Value
    ).success = "True",Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
 );
 Reset(DataCardValue2);
 Reset(ddProductType);
 Reset(ddUnit);
 Reset(ddSub_Unit);
 Reset(ddPJHQ_JOA);
 Reset(ActivityName);
 Reset(Act_St_DatePckr);
 Reset(Act_End_DatePckr);
 Reset(dd_Country);
 Reset(CB_Ent_Keywords);
 Reset(CB_Ent_Keywords_1);
 Reset(CB_Ent_Keywords_2);

 

 

 

 

Also rather write so many Reset create a variable at end of the code like below

 

 

 

Set(varReset,true);
Set(varReset,false)

 

 

 

and now to each control property Reset add only varReset that will reduce the code

 

 

ForAll(
    DataCardValue2.Attachments As Document,
IF(
    'UploadtoSP(2)'.Run(
       {
        contentBytes: Document.Value,
        name: Document.Name
       },
        ActivityName.Text,
        ddProductType.Selected.Value,
        ddUnit.Selected.Result,
        Text(
	        Act_St_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        Text(
            Act_End_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        dd_Country.Selected.Value,
	    ddPJHQ_JOA.Selected.Value,
        ddSub_Unit.Selected.'Sub-Unit',
        CB_Ent_Keywords.Selected.Value,
        CB_Ent_Keywords_1.Selected.Value,
        CB_Ent_Keywords_2.Selected.Value
    ).success = "True",Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
 );
Set(varReset,true);
Set(varReset,false)

 


If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

View solution in original post

5 REPLIES 5
SebS
Memorable Member
Memorable Member

Hi @robbo1 

 

It's looking like Your ")" are all over the place

 

If(ForAll(DataCardValue2.Attachments As Document,

'UploadtoSP(2)'.Run(
    {contentBytes:Document.Value,name:Document.Name},
    ActivityName.Text,
    ddProductType.Selected.Value,
    ddUnit.Selected.Result,
    Text(Act_St_DatePckr.SelectedDate,
    "[$-en-US]yyyy-mm-dd"),
    Text(Act_End_DatePckr.SelectedDate,"[$-en-US]yyyy-mm-dd"),
    dd_Country.Selected.Value,
    ddPJHQ_JOA.Selected.Value,
    ddSub_Unit.Selected.'Sub-Unit',
    CB_Ent_Keywords.Selected.Value,
    CB_Ent_Keywords_1.Selected.Value,
    CB_Ent_Keywords_2.Selected.Value.success ="True")),
    Notify("Uploaded successfully.",NotificationType.Success,10000),
    Notify("Upload failed.",NotificationType.Error,10000)
    );

 

try this code hope it sort some of the errors 


If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.
robbo1
Regular Visitor

Hi @SebS, thanks for replying! Apologies, that was a result of my clumsy attempt to fix it! Here is a neater version of the formula which is working - 

 

ForAll(
    DataCardValue2.Attachments As Document,
    'UploadtoSP(2)'.Run(
       {
        contentBytes: Document.Value,
        name: Document.Name
       },
        ActivityName.Text,
        ddProductType.Selected.Value,
        ddUnit.Selected.Result,
        Text(
	        Act_St_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        Text(
            Act_End_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        dd_Country.Selected.Value,
	    ddPJHQ_JOA.Selected.Value,
        ddSub_Unit.Selected.'Sub-Unit',
        CB_Ent_Keywords.Selected.Value,
        CB_Ent_Keywords_1.Selected.Value,
        CB_Ent_Keywords_2.Selected.Value
    )
 );
 Reset(DataCardValue2);
 Reset(ddProductType);
 Reset(ddUnit);
 Reset(ddSub_Unit);
 Reset(ddPJHQ_JOA);
 Reset(ActivityName);
 Reset(Act_St_DatePckr);
 Reset(Act_End_DatePckr);
 Reset(dd_Country);
 Reset(CB_Ent_Keywords);
 Reset(CB_Ent_Keywords_1);
 Reset(CB_Ent_Keywords_2);

 

 I guess my question is really - How do I Insert the IF statement for the notification without breaking it! 🤣

 

Your suggestion did not resolve the problem unfortunately.

 

SebS
Memorable Member
Memorable Member

@robbo1 

 

I'm a donkey 😛

 

You actually need to Wrap it 🙂

 

 

If(
    'Power Automate Flow to Run'.Run().success = "True",
    Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
);

 

 

 

 

 

 

 

 

ForAll(
    DataCardValue2.Attachments As Document,
IF(
    'UploadtoSP(2)'.Run(
       {
        contentBytes: Document.Value,
        name: Document.Name
       },
        ActivityName.Text,
        ddProductType.Selected.Value,
        ddUnit.Selected.Result,
        Text(
	        Act_St_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        Text(
            Act_End_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        dd_Country.Selected.Value,
	    ddPJHQ_JOA.Selected.Value,
        ddSub_Unit.Selected.'Sub-Unit',
        CB_Ent_Keywords.Selected.Value,
        CB_Ent_Keywords_1.Selected.Value,
        CB_Ent_Keywords_2.Selected.Value
    ).success = "True",Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
 );
 Reset(DataCardValue2);
 Reset(ddProductType);
 Reset(ddUnit);
 Reset(ddSub_Unit);
 Reset(ddPJHQ_JOA);
 Reset(ActivityName);
 Reset(Act_St_DatePckr);
 Reset(Act_End_DatePckr);
 Reset(dd_Country);
 Reset(CB_Ent_Keywords);
 Reset(CB_Ent_Keywords_1);
 Reset(CB_Ent_Keywords_2);

 

 

 

 

Also rather write so many Reset create a variable at end of the code like below

 

 

 

Set(varReset,true);
Set(varReset,false)

 

 

 

and now to each control property Reset add only varReset that will reduce the code

 

 

ForAll(
    DataCardValue2.Attachments As Document,
IF(
    'UploadtoSP(2)'.Run(
       {
        contentBytes: Document.Value,
        name: Document.Name
       },
        ActivityName.Text,
        ddProductType.Selected.Value,
        ddUnit.Selected.Result,
        Text(
	        Act_St_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        Text(
            Act_End_DatePckr.SelectedDate,
            "[$-en-US]yyyy-mm-dd"
        ),
        dd_Country.Selected.Value,
	    ddPJHQ_JOA.Selected.Value,
        ddSub_Unit.Selected.'Sub-Unit',
        CB_Ent_Keywords.Selected.Value,
        CB_Ent_Keywords_1.Selected.Value,
        CB_Ent_Keywords_2.Selected.Value
    ).success = "True",Notify(
        "Flow has run successfully.",
        NotificationType.Success,
        2000
    ),
    Notify(
        "Flow run has failed.",
        NotificationType.Error,
        5000
    )
 );
Set(varReset,true);
Set(varReset,false)

 


If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.
SebS
Memorable Member
Memorable Member

@robbo1 

 

Try above I edit it 🙂


If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.
robbo1
Regular Visitor

@SebS you are my hero - that worked! Thank you very much for your help! 😁👍

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,112)