0

I'm using sitecore 9.1.1. I have a scenario in which i want to trigger an action when a file is uploaded to the media library and trigger another action when i re attach a file to the previously uploaded file. I was able to customize the "uiUpload Processor" in order to trigger the first action when a file is uploaded.

enter image description here

Is there a similar way to customize the "attach" action??

enter image description here

1

You can do this by creating a custom processor for attachFile pipeline. Create a patch file like below -

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <processors>
      <attachFile>
         //Add the patch:before type where you want to add your procesor
        <processor type="xyz.foundation.className,xyz.foundation" mode="on" patch:before="processor[@type='Sitecore.Pipelines.Attach.CheckSize,Sitecore.Kernel']"/>
      </attachFile>
    </processors>
  <sitecore>
</configuration>

and code can be like this with pipeline arguments will be AttachArgs, make sure to include Sitecore.Pipelines.Attach namespace in class -

public class className
{
    public void Process(AttachArgs args)
    {
        //Some condition
        if (args.MediaItem.Title != "test")
        {
            //Some action
        }
    }
}
| improve this answer | |
  • Thanks alot for helping. Yes this worked with me (Y) – AmiraElEwady Sep 17 '19 at 14:15
2

It has been a while, if I am remembering correctly attach action will run the following pipeline you could potentially extend.

<attachFile argsType="Sitecore.Pipelines.Attach.AttachArgs">
</attachFile>
| improve this answer | |
  • Thank you so much. This is exactly what i was looking for. – AmiraElEwady Sep 17 '19 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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