Using Attachments to Trigger Rules

Home Forums Classic DFFS Using Attachments to Trigger Rules

Viewing 1 reply thread
  • Author
    Posts
    • #21124
      Notrega
      Participant

        I would like to trigger a rule if someone ADDS a file to a list item. The Attachment field is Boolean and only checks if there is something there, not if something is new. So I thought maybe you could count the number of attachments and then compare for change to trigger a rule in DFFS or a workflow.

        I checked the web and there wasn’t much that gave me hope. I did find one site that put the output to a cvs file, but it is not DFFS friendly. https://easysp.wordpress.com/2016/06/02/finding-number-of-attachments-items-wise-in-a-sharepoint-list/

        However I did notice they were using item.AttachmentFiles.Count so I tinkered with the code below, but I keep getting various errors depending on how I have it configured.

        I either get an undefined error or a function expected error. I tried it with a function name called by a rule and still no dice.

        I tried it like this
        var IAFC = spjs.dffs(item.AttachmentFiles.Count)
        and
        var IAFC = (item.AttachmentFiles.Count)
        and all versions in between. Even tried AttachmentId

        
        
        {
                        var IAFC = spjs.dffs(item.AttachmentFiles.Count);
                        var AFC = spjs.dffs("Attachment_Files_Count");
                        var NAFC =  Math.floor(IAFC + AFC);
        
                        setFieldValue("Attachment_Files_Count",NAFC);

        }`

        Thoughts? Suggestions?

      • #21138
        Alexander Bautz
        Keymaster

          You can add this snippet to your Custom JS:

          var attachmentCount = spjs.dffs.beforeProperties.Attachments.length;
          setInterval(function(){
          	var count = jQuery("#idAttachmentsTable tr").length;
          	if(count > attachmentCount){
          		attachmentCount = count;
          		spjs.dffs.triggerRule(["NewAttachment"]);
              }
          },1000);

          You must change “NewAttachment” to match the UniqueId of the rule you want to trigger.

          Alexander

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.