0

I have a small requirement , where in i have 2 lists say List A and List B.

In List B, i have a lookup column which is looking up to List A column.
Now on selection of Lookup column value in List B i want to bring in another column value from List A and append it to a choice field or a text field and dynamically change the text field to drop down if it is possible.

Hope you can help me out on this!

0

Per my knowledge, we can't save a dynamical value to choice field.

For your case, you could get data from list A by rest api and populate to a text field and save.

Sample code: enter image description here

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script>
        $(function () {
            //replace fields and list name as yours 
            $('select[Title="LookupParent"]').change(function () {
                var parentID=$(this).val();
                $.ajax({
                    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('parent')/items?$filter=ID eq " + parentID + "",
                    type: "GET",
                    async: true,
                    headers: {
                        "accept": "application/json;odata=verbose",
                        "content-type": "application/json;odata=verbose",
                    },
                    success: function (data) {                        
                        $('input[title="TextField"]').val(data.d.results[0].Title);
                    },
                    error: function (jqxr, errorCode, errorThrown) {
                        console.log(jqxr.responseText);
                    }
                });
            })
        })

    </script>
  • in the above example, i have employee name in place of lookup parent, and based on that information needs to be fetched. but i am unable to get the employee name from the other list which is in people picker. I am trying to pick the data and add to textfield and dynamically change that to dropdown. Could you kindly help me in the process to get names then maybe i can follow your answer give above. – jayant khushalani Oct 8 '18 at 9:50

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.