Discussions

Redirect User to Login Page when Errcode 22 is Received

  • 1.  Redirect User to Login Page when Errcode 22 is Received

    Posted 08-25-2020 16:42
    Edited by Nathan Moore 08-25-2020 16:43
    I am using a Rich Text Formula field to allow a user to click on a button (sent to them via email) and update a specific record using the API_EditRecord API. I've been able to achieve this affect with the formula below.

    The question I have: is it possible to redirect users that are not logged in to a login page instead of them receiving the API errcode 22 (shown below)? I am glad that it does not allow the user to update the record without them logging in, but I would like the user experience to flow to the login page instead of seeing a raw error code.

    Rich Text Formula Field
    var text bgcolor = "#07ad02";
    var text txtcolor = "white";
    var text style = "style=\"text-decoration: none; background:" & $bgcolor & "; border-radius: 5px; padding: 8px 20px; color: " & $txtcolor & ";
    display: inline-block; font: normal 700 24px/1 \"Calibri\", sans-serif; text-align: center; text-shadow: none;";
    var text URLTWO = URLRoot() & "db/" & [_DBID_PARENT_CHILD] & "?a=dr&rid=" & [Related Parent-Child];
    var text url = URLRoot() & "db/" & [_DBID_APPROVALS] & "?a=API_EditRecord" & "&rid=" & [Record ID#] & "&_fid_7=Approved" & "&_fid_16=" & ToText(User()) & "&_fid_15=" & ToText(Now()) & "&rdr="&URLEncode($URLTWO);
    "<a " & $style & " href=\"" & $url & "\">Approve</a>"


    Error Code 22 (from API_EditRecord)
    <qdbapi>
    <action>API_EditRecord</action>
    <errcode>22</errcode>
    <errtext>Sign-in required</errtext>
    <errdetail>The page you have requested can be viewed only by users who have signed in. Please sign in to proceed.</errdetail>
    </qdbapi>



    ------------------------------
    Thank you,

    Nathan Moore
    ------------------------------