Expand all | Collapse all

Change user role for any user through APIs

  • 1.  Change user role for any user through APIs

    Posted 08-24-2020 09:26
    Hi everyone,

    I have a query related to changing user access to any app. I am trying revoke access for any user from the app through formula URL field. For that I am using API_ChangeUserRole, but prior to that I need to fetch user ID and user Role and for that I am using API_GetUserRole and API_GetUserInfo.

    And I am putting below mentioned code in URL field.

    var text getUserID =  URLRoot() & "db/" & "main" & "?a=API_GetUserInfo" &  "&email=" & [Email ID];
    var text getUserRoleID = URLRoot() & "db/" & "XXXXXXXX" & "?a=API_GetUserRole" & "&userid="  
                                                   & URLEncode($getUserID);
    var text changeUserRole =  URLRoot() & "db/" & Dbid() & "?a=API_ChangeUserRole" & "&userid=" &
                                                        URLEncode($getUserID) & "&roleid=" & URLEncode($getUserRoleID) &
                                                       "&newRoleID=" & URLEncode(X);
    var text url = $getUserID & "&rdr=" & URLEncode($getUserRoleID)& URLEncode("&rdr="
                                                         &  URLEncode($changeUserRole));

    But when  I am trying to invoke the same, I am getting this error.
    <errtext>Unknown user</errtext>

    Would you please let me know what changes should I make in URL to get desirable result.
    #Thanks in advance

    Anchal Kumar Singh

  • 2.  RE: Change user role for any user through APIs

    Posted 08-25-2020 12:06
    In your first line your db where you have "main" needs to be changed to the actual dbid of your app. Click on the home button and then take that dbid from the URL. That is your main app id. The GetUserRole call also needs the same main db I just mentioned added here, if you have something different.

    You might also try changing your first line to this. var user getUserID = instead of text, might not matter though.