Forum Discussion
var text NewUserList = List(";",$MyUserList, totext(User()));
var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&_fid_99=" & $NewUserList;
var Text DoIt =
"javascript:" &
"$.get('" &
$URL &
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);";
if(not contains($MyUserList, Totext(User())),$DoIt) // only add the Current user iF not already subscribed
------------------------------
Mark Shnier (YQC)
Quick Base Solution Provider
Your Quick Base Coach
http://QuickBaseCoach.com
mark.shnier@gmail.com
------------------------------
- JimHarrison5 years agoQrew ChampionWorks like a button!
[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
------------------------------- JosephMahon2 years agoQrew Cadet
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
------------------------------