View Only
Expand all | Collapse all

How to Add CurrentUser to User List field

  • 1.  How to Add CurrentUser to User List field

    Posted 03-23-2020 17:45
    I have searched the API, formulas and community and don't see anything. Wondering if there is an API function for adding the current user to a User List through a URL Formula?

    The idea is to expose a button on a report that says Subscribe on it. When the User clicks the button their username is added to the User List field. The report is displayed on the App Home page, where each record is a separate topic of interest.

    We won't have a lot of Subscribers so a User List is ok. We want to experience to exclude opening the record and adding the User name to the list.

    This doesn't work:
    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid61=User()&apptoken=

    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid61=[??WHAT DO IT PUT HERE??]&apptoken=


    Jim Harrison


  • 2.  RE: How to Add CurrentUser to User List field

    Posted 03-23-2020 18:24
    var text MyUserList = Totext([userlist2]); // insert your List User field here

    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

  • 3.  RE: How to Add CurrentUser to User List field

    Posted 03-24-2020 16:32
    Works 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";
    "<a title=\"" & $title & "\"style =\"" & $style & "\"" & $target & "href=" & If([Subscribed]=1,$urlTwo,$url) & ">" & $btnName & "</a>"

    Thank you Coach!!

    Jim Harrison

  • 4.  RE: How to Add CurrentUser to User List field

    Posted 03-14-2023 19:38

    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

  • 5.  RE: How to Add CurrentUser to User List field

    Posted 03-15-2023 08:44

    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. 

    var text addtolist=ToText([61D. List-User Field])&";"&UserToEmail(User())&"";

    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

  • 6.  RE: How to Add CurrentUser to User List field

    Posted 03-21-2023 12:27

    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

  • 7.  RE: How to Add CurrentUser to User List field

    Posted 03-21-2023 13:33

    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();

    & "&rdr=" & URLEncode($RefreshPage)

    Mark Shnier (Your Quickbase Coach)

  • 8.  RE: How to Add CurrentUser to User List field

    Posted 03-21-2023 17:55

    This works perfect!  Thank you!

    One other thing I thought of.... Is there a way to get it to load the parent table but in view only mode.  

    This whole set up works, but the pipeline doesn't run fast enough and after pushing the button, we need to refresh the page for the pipeline to have taken effect. 

    Joseph Mahon

  • 9.  RE: How to Add CurrentUser to User List field

    Posted 03-21-2023 18:13

    Well, you can have the last line read 

    var text DisplayParent=  URLRoot() & "db/" & [_DBID_PARENT_TABLE_NAME]

    & "?a=dr& rid=" & [Related Parent];

    & "&rdr=" & URLEncode($DisplayParent)

    As for the issue of the embedded child table not updating quick enough due to the pipeline speed,  one trick is to have that embedded table be in a Tab which is not the main tab. That will force the user to click a Tab to display the child table and by the time they click the button there's a good chance the pipeline will have run. 

    What does the pipeline do when you click the URL Formula button? Perhaps the URL formula button itself can do the updates you need. 

    Mark Shnier (Your Quickbase Coach)

  • 10.  RE: How to Add CurrentUser to User List field

    Posted 03-21-2023 23:02

    I appreciate all of the help!  It is almost working perfect. The pipeline runs and the ultimate goal is achieved but I am getting an error with this code:

    var text Approve = If([Import Note Check Box] = false, URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#])
    & "&_fid_39=1",URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & ToText([Record ID#])
    & "&_fid_39=0");

    var text DisplayParent=  URLRoot() & "db/" & [_DBID_EPISODES_OF_CARE] & "?a=dr& rid=" & [Related Episode];

    & "&rdr=" & URLEncode($DisplayParent)

    I think it has to do with [Related Episode] 

    Here is the function:

    Our staff dictates notes into the child table while on the road.  When they come home and go into the Parent Table and click the URL button we are creating here. This checks a box on the child record and then triggers a pipeline.  The pipeline maps the fields from the child table to the parent table.  There are about 12-15 fields. 

    Joseph Mahon

  • 11.  RE: How to Add CurrentUser to User List field

    Posted 03-22-2023 01:06

    Take away the extra space in this line before rid.  

    "?a=dr& rid=" & [Related Episode];

    Mark Shnier (Your Quickbase Coach)

  • 12.  RE: How to Add CurrentUser to User List field

    Posted 03-22-2023 01:48

    That did it! Jeez, thanks for catching that.  I appreciate all of the help.

    This works perfect and looks nice and clean now!

    Joseph Mahon