Forum Discussion
[Subscribe Button]
var text SubscribersUL = ToText([Subscribers]);
var text UserListUpd = List(";",$SubscribersUL, ToText(User()));
var text btnName = If([Subscribed]>0,"Subscribed","+ Subscribe");
var text urlOne = If([Subscribed]>0,"",URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_<<[Subscribers_fid]>>=" & $UserListUpd & "&apptoken=<<app_token>>");
var text urlTwo = URLRoot() & "db/<<app Home page dbid>>";
var text url = $urlOne & "&rdr=" & URLEncode($urlTwo);
var text style = If([Subscribed]>0,[styleGrey],[styleAdd]);
var bool popup = false;
var text target = If($popup = true, "target = _Blank ", "");
var text title = "Add name to [Subscribers] User List";
//*****DO NOT EDIT BELOW THIS LINE*****
//HTML
"<a title=\"" & $title & "\"style =\"" & $style & "\"" & $target & "href=" & If([Subscribed]=1,$urlTwo,$url) & ">" & $btnName & "</a>"
Thank you Coach!!
------------------------------
Jim Harrison
------------------------------
I know this thread is old, but how could you remove a user from the list. For example, remove the current user from the list.
------------------------------
Joseph Mahon
------------------------------
- katlyncowley2 years agoQrew Assistant Captain
Hey Joseph, I just saw this in Kirk Trachy's Magic Buttons app!! Replace all instances of "[61D. List-User Field]" with your user list field. It works for both adding and removing.
//ADD TO LIST
var text addtolist=ToText([61D. List-User Field])&";"&UserToEmail(User())&"";//REMOVE FROM LIST
var text removefromlist= List(";",
If(Trim(Part(UserListToEmails([61D. List-User Field]),1,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),1,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),2,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),2,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),3,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),3,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),4,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),4,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),5,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),5,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),6,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),6,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),7,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),7,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),8,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),8,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),9,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),9,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),10,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),10,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),11,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),11,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),12,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),12,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),13,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),13,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),14,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),14,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),15,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),15,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),16,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),16,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),17,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),17,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),18,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),18,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),19,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),19,";")),
If(Trim(Part(UserListToEmails([61D. List-User Field]),20,";"))!=Trim(UserToEmail(User())),Part(UserListToEmails([61D. List-User Field]),20,";")));// Creating the addurl
var text addurl = URLRoot()&"db/"&Dbid()&"?a=api_editrecord&rid="&[Record ID#]&"&_fid_342="&$addtolist&"&apptoken=c7y3n83dz8fuc2n8jum5dzq4iky";// Creating the removeurl
var text removeurl = URLRoot()&"db/"&Dbid()&"?a=api_editrecord&rid="&[Record ID#]&"&_fid_342="&$removefromlist&"&apptoken=c7y3n83dz8fuc2n8jum5dzq4iky";// Running the button
If(Contains(UserListToEmails([61D. List-User Field]),UserToEmail(User())),"<a class=\"Vibrant Danger\" style=\"width:310px; text-align: center;\" href='" & $removeurl & "&rdr=" & URLEncode( URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl()) & "'>Remove Me From 41D. List-User Field</a>",
"<a class=\"Vibrant Success\" style=\"width:310px; text-align: center;\" href='" & $addurl & "&rdr=" & URLEncode( URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl()) & "')>Add Me To 61D. List-User Field</a>")
// This Formula Rich Text button BOTH ADDS AND REMOVES you from the 61D. List-User Field. You can use this as a way to opt in and opt out of a distribution list for notifications, subscriptions or to monitor happenings on a project.
// This works whether you are on a form, report, table home page or dashboard.// If you don't find the functionality you need, please log your requests at https://feedback.quickbase.com.
------------------------------
Katlyn Allen
kallen@eatatjacks.com
------------------------------- JosephMahon2 years agoQrew Cadet
Sorry I didn't respond sooner, I thought I had posted that this worked perfect.
I have another URL button question!
I have a button that will check or uncheck a check box. It works perfect! Here is my issue.
The button is displayed on a parent table via a link report. When I push the button from the parent table link report, it redirects me to the child record. My goal is to push the button from the link report and stay on the parent record in either edit or display mode.
The check box triggered by the button triggers a pipeline for the parent record, which is why I want to stay there.
Appreciate any help as I have tried everything!
------------------------------
Joseph Mahon
------------------------------- MarkShnier__You2 years agoQrew Legend
There is an example of some code which will set the value in a field and then refresh the page. The beauty of this is even though you might be pressing the button on a link from an embedded child record it will refresh the whole Quickbase page that you were already on and not just display the child record.
var text Approve = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#])
& "&_fid_144=Approved";var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();
$Approve
& "&rdr=" & URLEncode($RefreshPage)
------------------------------
Mark Shnier (Your Quickbase Coach)
mark.shnier@gmail.com
------------------------------