0

I have two lists. First one is a Projects List and Second List has a lookup column to the First list. I want the lookup column on Second list to show only the Projects filtered by the column "Created By".

In example: If John Doe Created a Project in the first list, then, John Doe will go to second list to create a record but The projects lookup column should only show projects created by John Doe and not all other project created by someone else. I am using Sharepoint 2016.

Your support is really appreciated.

Thanks

  • Can't you use workflow to create a new item in the second list with Project Name and Author column? – SharePointer Nov 22 '17 at 21:33
1

Use Rest Api on New form:

$("select[title^='Projects']").empty();

        $("select[title^='Projects']").append("<option value=''></option>");

        var listName='Projects';
        var currentUser='John Doe';
        var Query = _spPageContextInfo.siteAbsoluteUrl+ "/_api/web/lists/getbytitle('" + listName + "')/Items?$select=Projects/Title&$expand=Projects&$filter=Author eq '" + currentUser + "' ;

        $.ajax({
            url: Query,
            type: "GET",
            headers: { "accept": "application/json;odata=verbose" },
            success: function (data) {


                    var  jsonData= data.d;
                    var i =0;
                    var listItems="";
                    for (i = 0; i < jsonData.results.length; i++){
                     listItems+= "<option value='" + jsonData.results[i].Title+ "'>" + jsonData.results[i].Title+ "</option>";
                    }
                $("select[title^='Projects']").append(listItems);    

            },
            error: function (xhr) {
                console.log(xhr.status);

            }
        });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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