I'm pretty new to SharePoint. I've developed a console application that given an excel spreadsheet with user names in it it reads the excel and then delete the users whitin it in the Sharepoint Site. What i really want to do now is that this application is executed when a user with high privileges wants to. I've read something about tasks and jobs...But i dont really know where to start from. So what would be the best way to accomplish this? For example I would like a Task that lets the user upload an excel file and then the user clicks sth like "Start the Task" and my aplication runs to delete the users.
1 Answer
According to your requirement.
- You should create one document library where any user will upload your excel file.
- You should add one "Yes/No" column(lets say "Start the task") in document library for confirming from the user whether he/she want to perform actual.
- Then you should create one ItemUpdated event receiver for this document library and first check "Yes/No" field value in event receiver and if it is yes then you can write your code for removing users from SharePoint site
Following link will be use full
So as a output what end user will get
- User upload excel document into your document library and set "Start the Task" as yes if he/she want.
- Once user upload document, ItemUpdated event receiver will automatically fires and check the value of field "Start the Task" , and if it is set to yes then your code will be executed to remove the users from SharePoint site
- Suppose if user have not ticked "Start the task" field first time then your event receiver will be executed but it will not execute code for removing user's from SharePoint site as you have checked in event receiver. So in future whenever user want to execute that file then he comes to that document library and edit document fields and set "Start the task" field value to true"
Hope it will help to you..
-
Thanks for the suggestion! But since my task takes about 3 or 4 mins to perform i don't think it's very correct to bind it to an event handler. I was thinking more of binding it to a windows service. Any ideas on that?– ERedCommented Jun 2, 2015 at 12:11
-
Item Added event receiver will run in background so ultimately it will be same as Windows Service. Commented Jun 2, 2015 at 12:23
-
If you want an user to be able to trigger the action an event handler sounds like the best solution. You could use the event handler to fill some kind of a cue (SPWeb property bag) and use a timer job to process the cue, but this way you'll have some delay between the user action and the processing. Have a look at this link– AndreasCommented Jun 2, 2015 at 12:35