cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Notification success / DisplayName

Hello,

 

If(
    User().Email in Split(
        ThisItem.'Kto polubił';
        ";"
    );
    Notify("Możesz polubić propozycję tylko raz."; NotificationType.Error);
    Patch(
        IdeaBox_1;
        ThisItem;
        {
            Polubienia: ThisItem.Polubienia + 1;
            'Kto polubił': ThisItem.'Kto polubił' & ";" & User().Email
        }
    ))

 

 

I have this function on my button - it is for LIKE functionality.

 

I have two problems.

 

1) I have no idea how to add NotificationSuccess when patch action is sucessful.

One of the users tried to help me, but his solutions failed.

 

I would like to add a message:

 

Notify("Polubiono!"; NotificationType.Success);

 

Is that possible? 

 

 

Set(varRecord, Patch(your_code_here));
If(!IsBlank(varRecord),
    Notify("Your request has been submitted!", Notification.Success),
    Notify("Your request was not submitted", Notification.Failure)
);

 

I found this function but I have problems in using that.

 

Another question is that I have this sharepoint field 'Kto polubił' (who liked)

Is stores users e-mails and prevent them from liking propositions more than once (function Notification Failure)

It stores emails like that:

email;email;email

 

I would like to use this field to show list of users that liked. I made gallery, table, tooltip and others with this field and it worked! But it shows e-mail address. Is it possible to reformat this field to shows users name as it is more clear? In my organisation e-mails are a lot different from names.

25 REPLIES 25

Hi @Elitezone 

 

Let me post here the complete code and try to simplify it, 

 

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople,Email = User().Email)),Notify("Możesz polubić propozycję tylko raz.",NotificationType.Error),Set(varRecord,Refresh(ItemLikes);ClearCollect(TempTable,ThisItem.WhoLikedPeople);Patch(TempTable,Defaults(TempTable),{ 
DisplayName:User().FullName,
Claims:"i:0#.f|membership|" & Lower(User().Email), 
Department:"", 
Email:User().Email, 
JobTitle:"", 
Picture:""
});Patch(ItemLikes,ThisItem,{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord),Notify("Your request has been submitted!",NotificationType.Success),Notify("Your request was not submitted", NotificationType.Error));)

 

 

WhoLikedPeople is the SharePoint field of type person 

For the Claims , Departments , JobTitle .. etc , These are internal properties of the field in SharePoint, Do not change them 

 

For the +1 , I suggest not to use this field and use the below to display the count of the likes from the field using the below formula

 

CountRows(ThisItem.WhoLikedPeople) 

 

But if you want to have this field you can update it the last patch code.

The code doesn't throw any errors on my side

 

I hope it is more clear now

 

Best Regards 

Mark

 

@Mark-Shenouda 

Mark, but what is ItemLikes. Is this another Sharepoint field?

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople;Email = User().Email));Notify("Możesz polubić propozycję tylko raz.";NotificationType.Error);Set(varRecord;Refresh(ItemLikes);ClearCollect(TempTable;ThisItem.WhoLikedPeople);Patch(TempTable;Defaults(TempTable);{ 
DisplayName:User().FullName;
Claims:"i:0#.f|membership|" & Lower(User().Email); 
Department:""; 
Email:User().Email; 
JobTitle:""; 
Picture:""
});Patch(ItemLikes;ThisItem;{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord);Notify("Your request has been submitted!";NotificationType.Success);Notify("Your request was not submitted"; NotificationType.Error));)

I have a field Polubienia that is used as a number field that gather all likes. Is it like that?

If yes then I cannot change Refresh(ItemLikes) to Refresh(Polubienia) - because it forces me to take Refresh(ThisItem.Polubienia) value.

 

Given above function gives 21 errors on my side:

Unexepected signs x 4

Invalid type of argument

Filter function got invalid argument.

ItemLikes invalid name

Refresh invalid type of arguments

Patch invalid arguments

ClearCollect invalid arguments

Etecera

 

This is my Sharepoint field WhoLikedPeople

Elitezone_0-1601887694591.png

 

 

Hi @Elitezone 

 

ItemsLike is the datasource(SharePoint List name) ..

Also for the WhoLikedPeople field settings , you need to enable multiple selection.. 

field Polubienia that is used as a number field, You can ignore this for now and you can use the count as explained in previous post   

Apply these settings and let me know if the errors are fixed.

 

Best Regards

Mark Shenouda

 

@Mark-Shenouda 

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople;Email = User().Email));Notify("Możesz polubić propozycję tylko raz.";NotificationType.Error);Set(varRecord;Refresh(IdeaBox_1);ClearCollect(TempTable;ThisItem.WhoLikedPeople);Patch(TempTable;Defaults(TempTable);{ 
DisplayName:User().FullName;
Claims:"i:0#.f|membership|" & Lower(User().Email); 
Department:""; 
Email:User().Email; 
JobTitle:""; 
Picture:""
});Patch(IdeaBox_1;ThisItem;{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord);Notify("Your request has been submitted!";NotificationType.Success);Notify("Your request was not submitted"; NotificationType.Error));)

I have made some changes in Sharepoint to allow multiple selections and also changed ItemLikes to IdeaBox_1 (My sharepoint data source).

 

Now I have 17 errors.

 

Maybe something is about this delimeter ;; and gallery. This button is in gallery that has this function:

 

Sort(Filter(Search(AddColumns(IdeaBox_1;"AuthorName";'Utworzone przez'.DisplayName);SearchBox.Text;"Nazwa";"Opis";"AuthorName"); (Utworzony) >= DatePicker1.SelectedDate && (Utworzony) <= DatePicker2.SelectedDate +1); Utworzony; If(SortDescending2;Descending;Ascending))

It created AuthorName column.

 

And it affects your function. One of errors is AuthorName name not recognized.

 

I heard that it can be fixed with LookUp to avoid checking this column but I have no idea how to apply.

 

Rest of errors:

Name TempTable not recognized

Function Patch has invalid arguments

WhoLiked does not match with expected type Table. Found type Error.

varRecord name not recognized.

Function isBlanc invalid arguments.

Formula got ParenClose where expected EOF (end of formula).

 

Hi @Elitezone 

 

I am noticing the you changed some delimiters in the code I sent you, like in the patch action you replaces "," with ";"

Can you keep the format as I sent you 

 

Best Regards

Mark Shenouda 

@Mark-Shenouda 

This gives 6 errors:

 

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople,Email = User().Email)),Notify("Możesz polubić propozycję tylko raz.",NotificationType.Error),Set(varRecord,Refresh(IdeaBox_1);ClearCollect(TempTable,ThisItem.WhoLikedPeople);Patch(TempTable,Defaults(TempTable),{ 
DisplayName:User().FullName,
Claims:"i:0#.f|membership|" & Lower(User().Email), 
Department:"", 
Email:User().Email, 
JobTitle:"", 
Picture:""
});Patch(IdeaBox_1,ThisItem,{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord),Notify("Your request has been submitted!",NotificationType.Success),Notify("Your request was not submitted", NotificationType.Error));)

But polish delimeter is ; not ,

Even intellisense stopped working if I use your formula.

 

All errors are: Unexpected signs ParenClose instead of Error and Invalid number of arguments expected 2 and received 1.

When I am gradually changing your formula with polish delimeter the amount of errors is increasing.

 

Elitezone_0-1601899873945.png

 

 

Hi @Elitezone 

 

Lets focus on the main issue of the thread , related to the likes, So I recommend to try the code without any additional features like sorting or extra fields for now , till we pinpoint the issue.

 

Also incase you the Polish delimiters are different and you found errors 

I recommend to add the code by chunks , for example add simple if condition , then insert the real functions and conditions partially 

 

Best Rgerads

Mark

  

@Mark-Shenouda 

I have deleted all functions from gallery, but still there are 17 errors - no matter how I transform your code.

 

Maybe this is related to TempTable. That name is not recognized. I have no such a collection/table.

Should this function include creation of such a collection?

 

Elitezone_0-1601966309581.pngElitezone_1-1601966366812.png

This name is not recognized (TempTable).

Seems like all others errors are related to this.

 

Function is like that atm:

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople;Email = User().Email));Notify("Możesz polubić propozycję tylko raz.";NotificationType.Error);Set(varRecord;Refresh(IdeaBox_1);ClearCollect(TempTable;ThisItem.WhoLikedPeople);Patch(TempTable;Defaults(TempTable);{ 
DisplayName:User().FullName;
Claims:"i:0#.f|membership|" & Lower(User().Email); 
Department:""; 
Email:User().Email; 
JobTitle:""; 
Picture:""
});Patch(IdeaBox_1;ThisItem;{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord);Notify("Your request has been submitted!";NotificationType.Success);Notify("Your request was not submitted"; NotificationType.Error));)

Hi @Elitezone 

 

Can I suggest the below

- Change Chrome browser language to English for easier troubleshooting. 

- Apply the full formula that I sent before(Attached again below), If it works you can change the browser language back to Polish and the formula will adjust itself.

- If it is still not working, lets break down the formula and see where are the errors.

- I broke the formula to 3 parts, Try each one and see if it works by itself , for each part , if it didn't work or you got errors , Please send me screen shot of the errors 

- Please make sure to do the below after changing the Chrome language.

 

Part 1

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople,Email = User().Email)),Notify("Możesz polubić propozycję tylko raz.",NotificationType.Error),Notify("Sample Message",NotificationType.Information))

 

Part 2

Set(varRecord,Refresh(ItemLikes);ClearCollect(TempTable,ThisItem.WhoLikedPeople);Patch(TempTable,Defaults(TempTable),{
DisplayName:User().FullName,
Claims:"i:0#.f|membership|" & Lower(User().Email),
Department:"",
Email:User().Email,
JobTitle:"",
Picture:""
});Patch(ItemLikes,ThisItem,{WhoLikedPeople:TempTable}););

 

Part 3 

If(!IsBlank(varRecord),Notify("Your request has been submitted!",NotificationType.Success),Notify("Your request was not submitted", NotificationType.Error)); 

 

 

Full Formula

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople,Email = User().Email)),Notify("Możesz polubić propozycję tylko raz.",NotificationType.Error),Set(varRecord,Refresh(ItemLikes);ClearCollect(TempTable,ThisItem.WhoLikedPeople);Patch(TempTable,Defaults(TempTable),{
DisplayName:User().FullName,
Claims:"i:0#.f|membership|" & Lower(User().Email),
Department:"",
Email:User().Email,
JobTitle:"",
Picture:""
});Patch(ItemLikes,ThisItem,{WhoLikedPeople:TempTable}););If(!IsBlank(varRecord),Notify("Your request has been submitted!",NotificationType.Success),Notify("Your request was not submitted", NotificationType.Error));)

 

 

Best Regards

Mark

 

 

@Mark-Shenouda 

Today you teached me something very cool - changing language in browser change language in Power Apps - good for experiments.

Your formula works in basic mode when my Gallery is set to IdeaBox_1

 

Function after delimeter change:

If(!IsEmpty(Filter(ThisItem.WhoLikedPeople;Email = User().Email));Notify("Możesz polubić propozycję tylko raz.";NotificationType.Error);Set(varRecord;Refresh(IdeaBox_1);;ClearCollect(TempTable;ThisItem.WhoLikedPeople);;Patch(TempTable;Defaults(TempTable);{
DisplayName:User().FullName;
Claims:"i:0#.f|membership|" & Lower(User().Email);
Department:"";
Email:User().Email;
JobTitle:"";
Picture:""
});;Patch(IdeaBox_1;ThisItem;{WhoLikedPeople:TempTable});;);;If(!IsBlank(varRecord);Notify("Propozycja została polubiona!";NotificationType.Success);Notify("Nie udało się polubić propozycji"; NotificationType.Error));;)

I would love to stay in english power apps language but it changes date format and my app is becoming a mess - my users all are from Poland. Still great for debugging and copying some English function.

 

But now the other part:

 

When I apply filter to my gallery to work as before:

Sort(Filter(Search(AddColumns(IdeaBox_1;"AuthorName";'Utworzone przez'.DisplayName;"CategoryCombo";Kategoria.Value);SearchBox.Text;"Nazwa";"Opis";"AuthorName"); 

(If(IsBlank(Last(FirstN(ComboBox2.SelectedItems.Value;1)).Value);true; Last(FirstN(ComboBox2.SelectedItems.Value;1)).Value in Kategoria.Value)||
If(IsBlank(Last(FirstN(ComboBox2.SelectedItems.Value;2)).Value);true; Last(FirstN(ComboBox2.SelectedItems.Value;2)).Value in Kategoria.Value)||
If(IsBlank(Last(FirstN(ComboBox2.SelectedItems.Value;3)).Value);true; Last(FirstN(ComboBox2.SelectedItems.Value;3)).Value in Kategoria.Value))

&&(Utworzony) >= DatePicker1.SelectedDate && (Utworzony) <= DatePicker2.SelectedDate +1); Utworzony; If(SortDescending2;Descending;Ascending))

It shows error:

Function Patch got invalid argument

AuthorName does not exist.

 

Someone told me that I have to use LookUp if I use addcolumns, but I do not know how to apply:

LookUp(IdeaBox_1,ID=ThisItem.ID)

in this function.

 

Please kindly help and I think this will be over 🙂

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (6,616)