<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: UploadCollection upload request not getting triggered in the First Instance in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaa-p/12274858#M4598498</link>
    <description>&lt;P&gt;Hello Zayidu,&lt;/P&gt;&lt;P&gt;The reason might be the missing header  with CSRF token:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var sToken = this.getModel().getSecurityToken();
oUploader.addHeaderParameter(new sap.ui.unified.FileUploaderParameter({
	name: "x-csrf-token",
	value: sToken
}));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you are using at least UI5 library version 1.62, then another way would be using new control: &lt;A href="https://ui5.sap.com/#/api/sap.m.upload.UploadSet"&gt;https://ui5.sap.com/#/api/sap.m.upload.UploadSet&lt;/A&gt;. Check this &lt;A href="https://blogs.sap.com/2020/03/31/pending-upload-using-upload-collection/"&gt;blog&lt;/A&gt; from &lt;SPAN class="mention-scrubbed"&gt;prajnaparmita&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;I hope that helps a bit. &lt;/P&gt;&lt;P&gt;Regards
Greg&lt;/P&gt;</description>
    <pubDate>Mon, 19 Oct 2020 12:36:36 GMT</pubDate>
    <dc:creator>GregMalewski</dc:creator>
    <dc:date>2020-10-19T12:36:36Z</dc:date>
    <item>
      <title>UploadCollection upload request not getting triggered in the First Instance</title>
      <link>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaq-p/12274857</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
  &lt;P&gt;I am going thru a bizarre error for the past 24 hours. I have a requirement of Uploading Documents. Hence I am using the UploadCollection Element from Ui5 Library.&lt;/P&gt;
  &lt;P&gt;Everything is working fine but the only thing is the upload isn't happening in the first instance. I opened/reloaded my UploadCollection Page, when I click &lt;STRONG&gt;upload, beforeUploadStart&lt;/STRONG&gt; event handler gets triggered where I am setting the URL to post the document, Then it goes to the &lt;B&gt;uploadComplete&lt;/B&gt; handler; but by this time, a &lt;EM&gt;network request&lt;/EM&gt; should have been sent to the URL that I set on the &lt;B&gt;beforeUploadStart &lt;/B&gt;handler, but checking the Network Tab in the Dev tools, there isn't any request triggered.&lt;/P&gt;
  &lt;P&gt;The catch is when I select a document for the second time or so forth times as usual the &lt;B&gt;beforeUploadStart&lt;/B&gt; event handler gets triggered and once this handler completed executing, a network request has been sent to the URL path that I set on the &lt;B&gt;beforeUploadStart&lt;/B&gt; event handler. Why it isn't getting triggered on the first instance when I open/re-load the UploadCollection Page. Please find my code:&lt;BR /&gt;&lt;BR /&gt;Your immediate help is much appreciated.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;XML:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;UploadCollection 
id="idUploadCollection" 
maximumFilenameLength="100" 
maximumFileSize="100"
multiple="true" 
items="{path : 'FileModel&amp;gt;/Items', templateShareable : 'true'}" 
showSeparators="None" 
fileType="{fileTypes&amp;gt;/Items}" 
sameFilenameAllowed="true" 
uploadUrl="{URLModel&amp;gt;/url}" 
noDataDescription="Drop files or use the "Upload" button to upload" 
fileDeleted="onFileModelDelete" 
filenameLengthExceed="onFilenameLengthExceed" 
fileSizeExceed="onFileSizeExceed" 
mode="SingleSelectMaster" 
numberOfAttachmentsText="" 
typeMissmatch="onTypeMissmatch" 
uploadTerminated="onUploadTerminated"
uploadComplete="onUploadComplete" 
beforeUploadStarts="onBeforeUploadStarts"&amp;gt;
&amp;lt;items&amp;gt;
                      &amp;lt;UploadCollectionItem id="idUploadCollectionItem" 
                        mimeType="{FileModel&amp;gt;Files/0/Extension}"
                        fileName="{FileModel&amp;gt;Files/0/EscapedName}" 
                        documentId="{FileModel&amp;gt;ObjectGUID}" 
                        enableEdit="false" enableDelete="true"
                        visibleDelete="true" visibleEdit="false" press="onItemListPress"
                        url="/mims/member/download?objectType={FileModel&amp;gt;ObjVer/Type}&amp;amp;objectId={FileModel&amp;gt;ObjVer/ID}&amp;amp;objectVersion={FileModel&amp;gt;ObjVer/Version}&amp;amp;fileId={FileModel&amp;gt;Files/0/ID}&amp;amp;fileName={FileModel&amp;gt;Files/0/EscapedName}&amp;amp;fileExtention={FileModel&amp;gt;Files/0/Extension}"
                        selected="{FileModel&amp;gt;selected}"&amp;gt;
                      &amp;lt;/UploadCollectionItem&amp;gt;
                    &amp;lt;/items&amp;gt;
                  &amp;lt;/UploadCollection&amp;gt;


&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;STRONG&gt;Controller.js&lt;/STRONG&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;        /******************************************************************/
        // onBeforeUploadStarts
        /******************************************************************/
        onBeforeUploadStarts: function (oEvent) {
          let timestamp = new Date();
          let oUploadCollection = sap.ui.core.Fragment.byId(
            'idChangeFragment',
            'idUploadCollection'
          );

          let newURL =
            this.DOC_UPLOAD_URL +
            // Document Added On*
            '×tamp=' +
            timestamp;

          oUploadCollection.setUploadUrl(newURL);
          let uplCol = oEvent.getSource();
          let fu = uplCol._getFileUploader();
          fu.setUseMultipart(true);
          oEvent.getSource().setUploadUrl(newURL);
          uplCol.mProperties.mode = 'SingleSelectMaster';

          // Header
          let oCustomerHeader = new sap.m.UploadCollectionParameter({
            name: 'slug',
            value: oEvent.getParameter('fileName'),
          });
          oEvent.getParameters().addHeaderParameter(oCustomerHeader);
        },

        /******************************************************************/
        // onUploadComplete
        /******************************************************************/
        onUploadComplete: function (oEvent) {
          let oUploadCollection = sap.ui.core.Fragment.byId(
            'idChangeFragment',
            'idUploadCollection'
            ),
            cItems = oUploadCollection.aItems.length,
            i;
          for (i = 0; i &amp;lt; cItems; i++) {
            if (oUploadCollection.aItems[i]._status === 'uploading') {
              oUploadCollection.aItems[i]._percentUploaded = 100;
              oUploadCollection.aItems[i]._status =
                oUploadCollection._displayStatus;
              // oUploadCollection.aItems[i]._status = 'display';
              oUploadCollection._oItemToUpdate = null;
              break;
            }
          }
          this.getView().getModel().refresh();

          oUploadCollection.getModel('FileModel').setData(null);
          oUploadCollection.getModel('FileModel').refresh();
          oUploadCollection.getBinding('items').refresh();

        },

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks in advance.&lt;/P&gt;
  &lt;P&gt;Zayid&lt;/P&gt;</description>
      <pubDate>Sun, 18 Oct 2020 18:02:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaq-p/12274857</guid>
      <dc:creator>zayidu</dc:creator>
      <dc:date>2020-10-18T18:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: UploadCollection upload request not getting triggered in the First Instance</title>
      <link>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaa-p/12274858#M4598498</link>
      <description>&lt;P&gt;Hello Zayidu,&lt;/P&gt;&lt;P&gt;The reason might be the missing header  with CSRF token:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var sToken = this.getModel().getSecurityToken();
oUploader.addHeaderParameter(new sap.ui.unified.FileUploaderParameter({
	name: "x-csrf-token",
	value: sToken
}));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If you are using at least UI5 library version 1.62, then another way would be using new control: &lt;A href="https://ui5.sap.com/#/api/sap.m.upload.UploadSet"&gt;https://ui5.sap.com/#/api/sap.m.upload.UploadSet&lt;/A&gt;. Check this &lt;A href="https://blogs.sap.com/2020/03/31/pending-upload-using-upload-collection/"&gt;blog&lt;/A&gt; from &lt;SPAN class="mention-scrubbed"&gt;prajnaparmita&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;I hope that helps a bit. &lt;/P&gt;&lt;P&gt;Regards
Greg&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 12:36:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaa-p/12274858#M4598498</guid>
      <dc:creator>GregMalewski</dc:creator>
      <dc:date>2020-10-19T12:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: UploadCollection upload request not getting triggered in the First Instance</title>
      <link>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaa-p/12274859#M4598499</link>
      <description>&lt;P&gt;Helo Guys,&lt;/P&gt;&lt;P&gt;This post might help! &lt;A href="https://github.com/SAP/openui5/issues/786" target="test_blank"&gt;https://github.com/SAP/openui5/issues/786&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As for now, the UploadCollection Element is little buggy.&lt;/P&gt;&lt;P&gt;Here is what I did, I just set a URL model and I set the property&lt;STRONG&gt; url={URLModel&amp;gt;/url} &lt;/STRONG&gt;in the XML view, and on the controller init method I set the value of the URLModel. By this way the it got posted even on the first Instance of the Upload.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Oct 2020 12:39:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/uploadcollection-upload-request-not-getting-triggered-in-the-first-instance/qaa-p/12274859#M4598499</guid>
      <dc:creator>zayidu</dc:creator>
      <dc:date>2020-10-19T12:39:54Z</dc:date>
    </item>
  </channel>
</rss>

