SharePoint - Automation of Unfollowing Deleted Sites and Documents - sharepoint

Upon deletion of a site or document, I'd like the site/document to be deleted from everyone's "follow" list. However, it appears that is not happening. I've confirmed the "Activity Feed Timer Job" is functioning normally.
This is SP On Prem 2013

You have to do it yourself. The best way to do so by using event receivers. You have to check each user on the user profile and unfollow the item if they are following it.
For sites, you can use SPWebEventReceiver.SiteDeleting and for documents SPItemEventReceiver.ItemDeleting.

Related

Secure the 2-stages approval application using SharePoint & Power Apps & Power Automate

We have a travel request application. where a user submit a request which should go into 2 stages of approval process before it gets Final Approval.
Now we did the following:-
Create a SharePoint list which contain those fields; Title, Description, StareDate, EndDate, FirstApproval (the requestor direct manager), SecondApproval (the requester regional approval), Statues (system-generated with those options; open, first-approved, second-approved, Final-Approved).
Power Apps, which send emails to the first-approval and the second-approval users , and show-hide the Approved & Reject buttons based on the item status.
Power Automate,to set item-level permissions, so for example when the item needs first-approval only the approval's direct manager can edit the item, while all stakeholders can read-only.
now the process is not 100% secure, as a requestor using API call or using SharePoint built-in forms, can easily create a new request and define its status as Final-Approved. so in other words the requestor can bypass the Power Apps business logic. so how we can secure our process? so if an item has a status = "Final-Approved", then we can 100% sure that it actually went through the 2 approvals users?
One Approach i am thinking of, is as follow:-
To create additional SharePoint list >> which stores the ItemID + ItemStatus.
Grant all users Read-Only on this new list while grant the service account Contribute.
Update this new list from Power automate Only. so for example only if the submitter's direct manager did the approval, to change the status inside the new list to First-Approved, and so on.. Also only if the submitter's regional manager approve the request + there is already an approval from the direct manager to change the status from First-Approved to Second-Approval.. so what ever the status is inside the new lit i can be sure that it has not been hacked, as end-user will have read-only on this new list.. can anyone advice please?
Thanks
I believe this question is not unique to you, many SharePoint developers need to make specific configurations or use some artifices to ensure a certain process developed in SharePoint.
Using exclusive/custom permission control into List and uses the PowerAutomate layer to conntrol List Item permission only to approver will secures some update from Rest API, for example.
If you want to block New Insert items and/or block Update items by PowerApps, you can substitute the instruction into "OnEdit" and/or "OnNew" events using ResetForm(SharePointForm1);; RequestHide();; with this instructions in these events block some user to create or update SharePoint Items.
Into SharePoint list settings, in advanced settings, you can disable attachments, disable comments in list item, disable search, disable quick edit, disable launch form in dialog.
I think that's all.

Custom People Picker is not showing results from SharePoint Group, where users are added using the SPD workflow

I have a custom people picker that fetches users from a SharePoint Group, only when the users are added manually from the Group settings.
If i add the users via SPD Workflow, the people picker is failing to read the data.
Deleted the Users and tried the Workflow, it didnt work. Removed app step from workflow and tried, still no use.
Reference to add User to SPD Group using Workflow: http://codelesssharepointinfopath.com/workflow-useful-rest-calls-add-user-to-group/
Expected: People Picker should show the users from the SPD Group
Actual: No Results found
It's probably because it's a workflow (if you're using 2010 give 2013 a try). Do you get the same issue when you use Flow? If you don't get the same issue I think you need to force a refresh via the workflow. Worst case scenario you can use REST to add the user to the group through the workflow and I would imagine that would force a refresh.

SharePoint OOTB workflows 'Failed on Start' when started on create but can be started manually

I'm using the SharePoint Three-State workflow for a complete and then validate scenario on an InfoPath form. A web service creates the instance of the InfoPath form in the library. The idea is that the workflow will get a particular user to complete the form and then gets a manager to approve it. Simple stuff really.
The workflow fails to start unfortunately. The log shows an argument exception when it tries to start the workflow. Strangely it runs fine when manually started so that rules out the association data being incorrect. I've also tried this with other OOTB workflows such as Approval. I've thought it might also be the creation of the item through the web service but then it all works in my development environment.
I'm hoping someone might be able to contribute what I'm forgetting to check.
What identity is your workflow attempting to start under? If it is the SharePoint System Account, that account cannot start declarative workflows, as documented in this SharePoint Designer Blog post on MSDN.
This same problem impacted one of our workflows, where a web part programmatically created a list item and our workflow was set to trigger on item create and update actions. Manually creating items or manually running the workflow worked because it happened under our personal credentials.
Our solution was to simply create a service account in AD that the web part could impersonate. Once the list items were no longer being created under the System Account, the workflow worked as expected.
If you are receiving an argument error, I would check that the workflow is not referencing a field that would not be populated at the time of creating the list/library item. If you reference something like the ID field or a calculated column this field would not be available.

MOSS 2007 - Should I create a custom workflow or not?

I have a scenario where I want a user when viewing a list item to be presented with a custom action to create a site. This is pretty similar to the scenario provided in the MOSS 2007 SharePoint Guidance. What makes it different is that I want the site created with the url and name taken from the list item, and then a web propertybag value set. The only user task after the site is created is for the site collection administrator to add some specific user rights to it.
I can do everything apart from prompting the user to set the site rights via the object model so should I use a workflow or just code it straight?
The benefits of a workflow would be the ability to track the task and whether it has been completed or needs escalation etc.
The answer to this question is going to be found from your own staff on how they want to manage the tasks. An email notification may suite them better. Check with them on whether the benefits of a workflow are going to be worth the development cost.

SharePoint VS workflow emailing to a SharePoint group

I have a code activity that sends an email in a VS workflow. It simply sets the 'To' property to the name of a SharePoint group in the site collection. However, only the 1st person in the group gets emailed.
Any ideas why this is happening?
thanks
Does your group contain anything other than just users (ex: distribution lists, ad groups)?
If this is still a problem and you need to be able to send to a SharePoint group, I would recommend writing a custom workflow Action that would gather the emails of all the users in a specified group (you can find many tutorials online on how to make a custom action).
Turned out it was not even emailing the first user. I decided to extract the user emails programatically instead. Works fine.

Resources