0

Good Day, I have the non-standard task. I have SharePoint Document List and Directory List. The Directory List includes three columns: “Process” (single-line field), “Process Group” (choice field), “Process Region”. The Document List has “Process”, “Process Group”, “Process Region” fields too.

In the Directory List one Process Region includes several Process Groups, one Process Group includes several Processes. The Directory List includes 100 list elements with filled “Process”, “Process Group”, “Process Region” fields. I must create “Select Process” button on this Document List NewForm. The user wants to click this button and see Popup window. The Popup window must display hierarchy “Process Region”, “Process Group”, “Process” from Dictionary List like Tree. The user must click some process in Modal Window and that Process and his “Process Group”, “Process Region” values from Directory must become a field values “Process”, “Process Group”, “Process Region” on Document NewForm.aspx

Do the SharePoint standard methods to do that exist? Where can I see some JS code example to past values from Dictionary List to Modal Window, then past selected values from Modal Window to Document Form fields?

Thanks for any idea.

1 Answer 1

1

I found the solution To NewForm I added this script to Script Editor Web Part

<script type="text/javascript" src="/SiteAssets/Script/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/SiteAssets/Script/jquery.SPServices.min.js"></script> 
<script>

              function demoCallback(dialogResult, returnValue)
              {
              
                 if (dialogResult === SP.UI.DialogResult.OK) // Perform action on Ok.

                         {

                          console.log ("This is return value " + returnValue);

                        }
              }
              


function openDialog(pageUrl) {
var options = {
 url: pageUrl,
 title: '',
 allowMaximize: false,
 showClose: true,
 width: 900,
 height: 1500,

    dialogReturnValueCallback: demoCallback
    }
 
 SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options); }
</script>

This script I added to List view which I show in modal window

<style type='text/css'>
    #allTitle, #titlerow, #spFooter, #suiteBarDelta{
        display: none;
    }
    #ms-designer-ribbon{
        display: none;
    }
    .ms-csrlistview-controldiv{
        display: none;
    }

</style>
<html>
<div class="selectButtons" unselectable="on" style="float:left; margin-left:50px;">
    <button onclick="closeDialogOK()" id="btnSelectContact" type="button" unselectable="on">Ok</button>
    <button onclick="closeDialogCancel()" id="btnCancel" type="button" unselectable="on">Cancel</button>
</div>
</html>

<script type="text/javascript" src="/SiteAssets/Script/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="/SiteAssets/Script/jquery.SPServices.min.js"></script> 
 
<script type="text/javascript">
 
    var selectedId = '';
 
    function closeDialogOK() {
 
        $(".s4-itm-cbx ").each(function () {
            
            
            var checked = $(this).attr('aria-checked');
            if (checked === "true") {
               // selectedId  = $(this).closest('tr').find('.ms-vb-title ').children('div')[0].id;
               selectedId  = $(this).attr('aria-label');
                console.log(selectedId );
            }
        });
        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, selectedId );
    }
 
    function closeDialogCancel() {
        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel, 0);
  }
  
</script>
1
  • Thank You! imho link to original post could be useful too..
    – Gennady G
    Commented Aug 26, 2020 at 17:58

Your Answer

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

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