0

One of the Projects I am working on, I have a requirement to rename the file name while uploading it to the SharePoint document library.

The flow is as follows: Basically the Document library has a lookup column called Entity ID so when a user clicks on Upload in the document library, he or she will select the document to upload from their local machine, hit ok and then will select Entity ID(lookup column) from the drop-down as its a mandatory field to be populated. Lastly user will hit on Checkin button and the document will be uploaded.

Let's say the File Name user uploaded was as: "Accounting Info" and Entity ID was "11055", Now when the user hits on CheckIn, I want to rename the file name by appending the selected entity id at the end of the file name. So the replaced file name would look like: "Accounting Info 11055".

I want to achieve this using JSOM only since I am working with Office365/SharePoint online. Can someone please help me with the JSOM code to accomplish this? Many Thanks in Advance.

  • Is using Flow for this not an option? – Kasper Bo Larsen May 1 '18 at 16:45
  • @KasperBoLarsen, I have no idea if that is doable through flow as I also have to append the entity id to the document name for renaming purpose so I am seeing this to be done only using JSOM or CSOM. – mdevm May 1 '18 at 16:57
  • @KasperBoLarsen , unless a remote event receiver is in play, which I doubt in this case, the Flow is probably the best option. If you add that as an answer I'll give you an upvote. The OP should be able to extract the Entity ID in the Flow. – Derek Gusoff May 1 '18 at 17:04
  • @DevangMistry you won't be able to do this in JavaScript because there's no event to hook into. The Flow is probably your best bet. – Derek Gusoff May 1 '18 at 17:05
  • Thanks @KasperBoLarsen. I updated the post and added Flow as an answer as well. Can you help me how would I do this using flow? Thanks again. – mdevm May 1 '18 at 17:13
2

I would use Flow or Logic App for that kind of workflows, as that is what they are intended for 😊

However old school workflows might olso be an option due to the site template requirement

  • Can you provide more info, which template should i go for since I have not really used Flow. Thanks again. – mdevm May 1 '18 at 18:23
  • I am sorry but I can't go the Flow route as this will be applied to a library in bunch of sites in the site collection. So the code will be a part of site template. – mdevm May 1 '18 at 18:37

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.