Normalmente in una lista SharePoint Classic per aggiunge un allegato è necessario premere il pulsante Allega file sulla ribbon
Allega file
Allega file
con l'aiuto della Script Editor Web Part, inserita in una pagina di edit e/o new, è possibile inserire il controllo direttamente nel form

Per farlo è sufficente inserire questo JavaScript nella Script Editor Web Part

JavaScript

<script>
function sgartCustomForm() {
  var fieldFound = false;
  var elmRemove = document.getElementById("partAttachment");
  var elmTable = document.querySelector(".ms-formtable tbody");
  if(elmTable !== null && elmRemove !== null) {
    elmRemove.innerHTML = "";
    var elm = document.createElement("tr");
    elm.innerHTML = '<td width="190px" valign="top" class="ms-formlabel"><h3 class="ms-standardheader"><nobr>Foto annuncio</nobr></h3></td>'
      + '<td width="480px"  valign="top" class="ms-formbody" id="attachmentsOnClient"><span dir="ltr">'
      + '<input type="file" name="fileupload0" id="onetidIOFile" size="56" title="Nome">'
      + '<input name="Button1" type="button" value="Aggiungi" onclick="OkAttach()" style="width: 6em;">'
      + '</span></td>';
    elmTable.append(elm);
    fieldFound = true;
  } 
  if (fieldFound === false) {
    // se il form non è ancora stato caricato, riprovo...	
    console.log("sgartCustomForm retry");
    setTimeout(sgartCustomForm, 400);
  }
}
SP.SOD.executeFunc("sp.js", "SP.ClientContext", sgartCustomForm);
</script>
Tags:
JavaScript184 Script85 SharePoint497 SharePoint 201667
Potrebbe interessarti anche: