none
Connecting Lists in a Webpart RRS feed

  • Question

  • I've connected my Parent List to my Child List in the view and edit screens, but also want the Child List to show the Parent List in the view and edit. Is this possible? I've tried many different combinations and couldn't the Parent List to show with the Child.

    Thanks

    Kim

    Thursday, February 9, 2017 12:56 PM

Answers

  • Hi,

    I think you could get related parent list item by jsom in view/edit form, below is sample code for your reference.

     <script src="https://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                ExecuteOrDelayUntilScriptLoaded(getCurrentListItem, "sp.js");
            })
            function getCurrentListItem() {
                var context = SP.ClientContext.get_current();
                var web = context.get_web();
                var currentList = web.get_lists().getById(_spPageContextInfo.pageListId);
                var currentListItem = currentList.getItemById(getQueryStringParameter("ID"));
                context.load(currentListItem);
                context.executeQueryAsync(
                function (object,sender) {
                   var ParentItemID=currentListItem.get_item('LKP').get_lookupId();
    			alert(ParentItemID);
                    
                });
            }
            function getQueryStringParameter(paramToRetrieve) {
                var params = document.URL.split("?")[1].split("&");
                for (var i = 0; i < params.length; i = i + 1) {
                    var singleParam = params[i].split("=");
                    if (singleParam[0] == paramToRetrieve) return singleParam[1];
                }
            }
        </script>

    Best Regards,

    Lee


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, February 10, 2017 2:55 AM