Question

How to restrict maximum  number of files that can be dragged and Dropped into the control(pzmultidraganddropcontrol)?

Steps to ReproduceAdd few records in drag and drop control and try retriving the count of uploaded records

@Attempted SolutionsThe below Code Snippet was tried within the control and it did not retrive the correct value for count int i; ClipboardPage pgDD = null; pgDD = tools.findPage( "dragDropFileUpload" ); i = pgDD.getProperty( "pxResults" ).size();

Message was edited by: Attached Document is the Complete Code Snippet for the Control

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
August 4, 2015 - 4:23pm

Hi Ashok, Good Morning!

  • so, I learn it as ... at one go, drag & drop of attachments should be within a limit...
  • is the limit configured on number of attachments user drag & drop? or on the size of attachment?
  • we could attach a very less size files up to 100 & ONE file in GB of size...(an edge case, sorry)
  • to limit attachment size...
    • In 7x please refer OOTB system setting RULE-ADMIN-SYSTEM-SETTINGS PEGA-PROCESSENGINE PYMAXDRAGDROPATTACHSIZEMB #20140801T111621.066 GMT
      • prior 7x, by default, file attachments are restricted to 25 megabytes in size.
        • We can set a larger or smaller limit with the prconfig.xml file setting
          • <env name="Initialization/MaximumFileUploadSizeMB" value="nn" />
            • where nn is the size in megabytes
  • to limit # attachments... we could do a property-set-message
    • add Page-Set-Messages if @(Pega-RULES:Utilities).LengthOfPageList(dragDropFileUpload.pxResults)>5 in activity pyUploadFile in class Data-WorkAttach-File
      • UI should also be customized to include @baseclass.DisplayErrors on upload file dialog, though.
        • if this works, we could attempt for a wrapper activity calling pyUploadFile followed by custom validation activity.
  • for both the use cases, it would be nice to prompt user with an information text on load of attachments.screen

Please share your thoughts/comments, Thank you!

psahukaru

Comments

Keep up to date on this post and subscribe to comments

July 27, 2015 - 3:21am

The code looks fine to me. It should retrieve the number of documents in pipeline (uploaded) but not yet attached (saved to db).

What is the expected 'correct value'? The number in pipeline or number of actual attachments.

July 27, 2015 - 3:27am
Response to Vikas@Multichannel

Its the Number in PipeLine

July 27, 2015 - 3:37am
Response to Vikas@Multichannel

Hi Vikas, , we are looking for number in pipeline

Need to get the size the of the pagelist  from the control do determine the No of files that are already dragged into the dropdown

Clipboard.png

In this case , "i" should return 2, but it always returns zero.

Ideally the Below code should work when called from the section as well, but this is not working ., Need to check for alternatives

The same code is working fine from  an SaveAllattachments OOTB activity.

SaveAllAttachments.png

July 27, 2015 - 7:44am

If you're always getting 0, my guess is one of two things:  Either you're looking at a different property than the one that gets actually updated, or you're looking at the right property but there hasn't yet been a round-trip to the server so the property hasn't been updated yet.

To check for the first guess , try examining the entire page before and after, and compare, to see what properties are getting updated, if not the one you expected.

To check for the second guess, record using fiddler to see when the actual round-trip to the server takes place.  /Eric

July 28, 2015 - 3:47am
Response to ericosman_GCS

Hi Eric,

As per your suggestion, I've checked Fiddler and see that server round trips are indeed happening and we are referring to the correct property.

Unlike other code-pega-list pagelists ,  drapdropFileUpload  does not have a pxResultCount property , is this the reason for not getting the size??

This Clipboard page in generated by OOTB pega rules.

Fiddler.png

Pega
July 28, 2015 - 4:30pm
Response to CLARKAARONP

would it be convincing to work-a-round as below...

  • add Page-Set-Messages if @(Pega-RULES:Utilities).LengthOfPageList(dragDropFileUpload.pxResults)>5 in activity pyUploadFile in class Data-WorkAttach-File
    • UI should also be customized to include @baseclass.DisplayErrors on upload file dialog, though.
  • disable add attachments feature if @(Pega-RULES:Utilities).LengthOfPageList(AllAttachments.pxResults)>5

Please share your thoughts/comments, Thank you!

psahukaru

July 31, 2015 - 9:25am
Response to sahup1

Hi Phani,

This will not solve our purpose, Our idea is not to restrict the number of attachements that  are allowed for a work object,

The idea is just to limit the no of attachments being dragged and dropped into the control at a time ,

Since if the user drops 100 files at a time with huge size then it out take lot of clipboard size and lead to OOM exceptions and at times bringing down the JVMs.

In order to avoid this we wanted to put a restriction, on the number of file that can be uploaded at  one single go.

Pega
August 4, 2015 - 4:23pm
Response to CLARKAARONP

Hi Ashok, Good Morning!

  • so, I learn it as ... at one go, drag & drop of attachments should be within a limit...
  • is the limit configured on number of attachments user drag & drop? or on the size of attachment?
  • we could attach a very less size files up to 100 & ONE file in GB of size...(an edge case, sorry)
  • to limit attachment size...
    • In 7x please refer OOTB system setting RULE-ADMIN-SYSTEM-SETTINGS PEGA-PROCESSENGINE PYMAXDRAGDROPATTACHSIZEMB #20140801T111621.066 GMT
      • prior 7x, by default, file attachments are restricted to 25 megabytes in size.
        • We can set a larger or smaller limit with the prconfig.xml file setting
          • <env name="Initialization/MaximumFileUploadSizeMB" value="nn" />
            • where nn is the size in megabytes
  • to limit # attachments... we could do a property-set-message
    • add Page-Set-Messages if @(Pega-RULES:Utilities).LengthOfPageList(dragDropFileUpload.pxResults)>5 in activity pyUploadFile in class Data-WorkAttach-File
      • UI should also be customized to include @baseclass.DisplayErrors on upload file dialog, though.
        • if this works, we could attempt for a wrapper activity calling pyUploadFile followed by custom validation activity.
  • for both the use cases, it would be nice to prompt user with an information text on load of attachments.screen

Please share your thoughts/comments, Thank you!

psahukaru

August 5, 2015 - 8:54am
Response to sahup1

Hi Phani,

we are on 6.3 SP1 and have already handled the maxfile size and type of files that are allowed.

I'm also able to handle the max no files by using a local variable i and increment it for each file ,

But wanted to get the count dynamically, so wanted to get the size of dragDropFileUpload

Attached the complete code that we are using on the Original parent post,

just do a private checkout of pzmultidraganddropcontrol rule and copy the code into the control and run it ,

Note : this a  final rule , but we have customized it for our application

August 10, 2016 - 2:55am
Response to sahup1

This solved the issue. Thanks

July 28, 2015 - 7:41am

>>> drapdropFileUpload  does not have a pxResultCount property , is this the reason for not getting the size??

Hmmm, I'm not sure if that's the reason.  If you can put in a temporary on-change handler that tallies and supplies a .pxResultCount, (or maybe you can find a simpler way to supply a .pxResultCount) you can see if the issue goes away.  Or, if you look at how your ".size" function works to see if it relies on .pxResultCount.  Or just fill in .pxResultCount and call .size again to see whether it gives the correct answer.  /Eric

July 31, 2015 - 9:26am
Response to ericosman_GCS

Thanks Eric , I will check on this and get back.

August 4, 2015 - 11:12am
Response to CLARKAARONP

Created a test section and run the following and got output for all attachement  page.

<%

int Result=0;

String strDDPageName = "AllAttachments";

ClipboardPage cpDrgDrpFU = tools.findPage( strDDPageName );

ClipboardProperty pResults = cpDrgDrpFU.getProperty( "pxResults" );

Result= pResults.size();

%>

<html>

<%= Result%>

</html>

It worked fine at my end.

August 5, 2015 - 5:05am
Response to OptimusPrime

Hi Gaurav,

Yes, it is working for other Pagelists, but it is not working specifically for dragDropFileUpload