Here is my foundation setup. create two list

1.项目联系人信息: Contains master data that provides lookup values to test3

2.test3 Contains values and one column to lookup values from [项目联系人信息]

                <script type="text/javascript">
        function getMaxID(lsttitle){
        var mx = 0 ;$.each($('select[title="'+lsttitle+'"] option'),function(i,v){
            mx=Math.max(mx, v.value)
        return mx;
    function openDialog(pageUrl,lsttitle) { 
    var options = {
        url: pageUrl,
        title: lsttitle,
        allowMaximize: false,
        showClose: true,
        width: 700,
        height: 600,
        dialogReturnValueCallback: function(result,returnValue){
            if (result == SP.UI.DialogResult.OK) {

                    newcontactid = getMaxID(lsttitle)

            if (result == SP.UI.DialogResult.cancel) {
                //do nothing, modal was closed
    SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);       

        function newcontactonclick(){
        url = "https://alphafp.sharepoint.com/teams/Marketing/Lists/List2/newContact.aspx"
        openDialog(url, 'contactname')
    refreshcontact = function(lsttitle){
    //  lstName = lsttitle=="项目中介信息"?'中介联络人':lsttitle

            relationshipList: "项目联系人信息",
            relationshipListColumn: "Title",
            columnName: "contactname",
            CAMLQuery: "",
            completefunc: null,
            debug: false


and here is the button the opens the dialog, when new record is saved from the dialog, it refreshes the combobox using "refreshcontact" function as above.

<div style="padding:5px;margin-left:5px !important;">
                        <a href="#" onclick='javascript:newcontactonclick()' style="float:left;display:inline;"


The testing step is:

  1. Create new item using new form.
  2. Add new lookup item using the dialog
  3. Then refresh the selection box with JS.
  4. save the list

And it ends up an error page, the funny thing is that I have another input but using multiple select, which works fine...

  • Update 1; After I switch the lookup field causing the error to multiple select, it works.
    – RAY
    Nov 7 '18 at 18:43

Your Answer

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

Browse other questions tagged or ask your own question.