I would like to develop a user control with a text box where the user will enter his/her UserID and click the button to see some info which is populated by my own REST API.

Is there a web part out of box which I can leverage to do this kind of functionality?

I have a SharePoint site collection created by Teams. I'm the site collection admin of this team site. I would like to deploy in this site.

1 Answer 1

 <input type="text" name="userID" id="userID"><input type="button" onclick="getUser()" value="submit">
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
    function getUser() {
        let id = $("#userID").val();
            type: "GET",
            url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + id + ")",
            headers: {
                "accept": "application/json;odata=verbose",
                "content-type": "application/json;odata=verbose",
            success: function (data) {
            error: function (xhr, textStatus, errorThrown) {
                alert("No user");
            alert("please enter user id")

You could get user info in data.d,you could show the user info which you wanted to page. Test result: enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.