Forum Discussion

kheatley's avatar
kheatley
Qrew Member
2 months ago

Rich-text formula button on dashboard

Would love to create a rich-text formula button on dashboard that will create a new record in LEAVE REQUESTS table where Related Faculty = User.  Here's my try at a formula:

var text facultyRecordID = ToText(
    GetFieldValues(
        GetRecords("{'[FACULTY EMAIL]'.EX.'" & UserToEmail(User()) & "'}", "FACULTY"),
        [Related FACULTY]
    )
);

var text ButtonWords = "New Leave Request";

var text urlONE = URLRoot() & "db/" & [_DBID_LEAVE_REQUESTS] & "?a=API_GenAddRecordForm&_fid_15=" & $facultyRecordID
& "&apptoken=$APPTOKEN";

var text urlTWO = URLRoot() & "db/" & [_DBID_LEAVE_REQUESTS] & "?a=q&qid=11";

var text url = 
$urlONE 
//& "&rdr=" & URLEncode($urlTWO);
& "&NextURL=" & URLEncode($urlTWO );

// Begin button style
var text bgcolor = "#b71a1a";
var text txtcolor = "white";
var text style = "style=\"text-decoration: none; text-align: center; background:" & $bgcolor & "; border-radius: 5px; padding: 8px 10px; color: " & $txtcolor & "; display: inline-block; font: normal 800 14px/1 'Calibri', sans-serif; text-shadow: none; text-transform: uppercase;\"";
// End button style

"<a class='SaveBeforeNavigating' href='" & $url & "' " & $style & ">" & $ButtonWords & "</a>"

Problem is, I'm not sure where/how to do it.  Any advice?

  • You cannot simply have a dashboard button dynamically do a formula.  So you would need to create a report with on record on it  and one button on that Report, and put thzt small report on a Dashboard.  That's assuming that you code works on the report.

  • You cannot simply have a dashboard button dynamically do a formula.  So you would need to create a report with on record on it  and one button on that Report, and put thzt small report on a Dashboard.  That's assuming that you code works on the report.

  • Kim,

    Mark is correct.  This is a real issue in QB but the reason is sound.   Rich Text buttons draw upon the table where the field is created.   A button on a dashboard does not do that.  You can put on a button that will create a record and use the Add Form for the Role of that User, but  you cannot pass any variable into it.

    However, for the one business case where you want to relate a person that created the record, there is a back door.

    Set up a Pipeline to check the Leave Request records when they are added.  If the Related Faculty is Null, you can then search the Faculty table for the Faculty Member that matches the Record Owner.  You then update the Leave Request record with the correct Related Faculty Member.

     

     

    • kheatley's avatar
      kheatley
      Qrew Member

      Thanks for help.  I implemented Mark's fix using filter where faculty = current user.  :)