Create entity with assigned user and delete followers by API
Collapse
X
-
For anyone who finds this thread and wants to implement a solution, it is quite simple once you know which file to edit. I submitted PR. If it is not accepted, I will continue to maintain the functionality for my own use because it dramatically lowers the number of notifications in my environment. -
fernando.giacomino,
It's good that you made it work.
Just in case, I show the screenshots of actions in Workflow that remove all followers (actions must be placed in a set order, as in the screenshots):
Execute Formula Script Code:
Code:$getResponce = json\retrieve($_lastHttpResponseBody, 'list'); $getResponceEncode = json\encode($getResponce); $i = 0; $followersIds = list(); while( $i < array\length($getResponce), ( $followersIds = array\push($followersIds, json\retrieve($getResponceEncode, string\concatenate('', $i, '.id')) ); $i = $i + 1; ) );Last edited by lazovic; 04-05-2023, 05:50 PM.Leave a comment:
-
Sorry, with that data works fine. Sending DELETE to "myEspoUrl/api/v1/myEntity/myEntityId/followers" with payload {'id': 'currentFollowerUserId'} I receive response 'true'. Thanks for the help! -
I wish to buy advanced pack, love workflows and bpm, but euro exchange rate right now in our country is too high. Anyway, that action works, clean that user from followers, but sends an error response: TypeError: Cannot read properties of undefined (reading 'id')Leave a comment:
-
fernando.giacomino,
Please see the following screenshot:
This is a screenshot of Send HTTP Request Action in Workflow (a feature from the Advanced Pack extension) that removes the User from the list of followers of the record he/she created.
As you can see, the DELETE method with the filled payload is being used here. This solution works great, I tested it.
So, in this case, I suggest that you familiarize yourself with the Advanced Pack extension and Workflows, if you do not already have it, on the demo or cloud version of EspoCRM, or if your service for sending requests allows you to use the DELETE method with a filled payload, use it.Leave a comment:
-
Some testing: if I make a PUT with that route "/subcription" and {'isFollowed':false} as payload, api adds the api user as follower! If then I make a DELETE to that route, take off the api user from the followers list, but no wipe out other followers.Leave a comment:
-
But no, http delete was ok, code 200, but actually no change was made on entity followers list.Leave a comment:
-
Please keep in mind that my solution is not absolutely correct and it is better not to use it too often, only when creating a record, as you are doing now. -
Thanks lazovic! That route works perfect. I copy "/followers" route from webbrowser console when manually delete followers.Leave a comment:
-
Hi fernando.giacomino,
Please try to use the following HTTP request: myespourl/api/v1/myEntity/Entity_Id/subscription, with DELETE method and without payload.
Perhaps it will suit you.Leave a comment:
-
Create entity with assigned user and delete followers by API
Hello! I've created a custom entity and set up throught API an assigned user, but I don't want that user to be a follower of that entity (unless he does it manually after).
My http call goes to: "myespourl/api/v1/myEntity/Entity_Id/followers" with method "DELETE" and without payload.
Response is code 404, any other http request is working fine. Permissions for the role and api user are: "Follower Management Permission" to All and myEntity permissions full access. Any help is wellcome!

Leave a comment: