Announcement

Collapse
No announcement yet.

Create entity with assigned user and delete followers by API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • lazovic
    replied
    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):

    Click image for larger version  Name:	image.png Views:	0 Size:	44.9 KB ID:	90325
    Click image for larger version  Name:	image.png Views:	0 Size:	22.6 KB ID:	90326

    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:


  • fernando.giacomino
    commented on 's reply
    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!

  • fernando.giacomino
    replied
    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:


  • lazovic
    commented on 's reply
    Now I'm working on deleting all followers.

  • lazovic
    replied
    fernando.giacomino,

    Please see the following screenshot:

    Click image for larger version

Name:	image.png
Views:	344
Size:	22.3 KB
ID:	90312

    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:


  • fernando.giacomino
    replied
    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:


  • fernando.giacomino
    replied
    But no, http delete was ok, code 200, but actually no change was made on entity followers list.

    Leave a comment:


  • lazovic
    commented on 's reply
    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.

  • fernando.giacomino
    replied
    Thanks lazovic! That route works perfect. I copy "/followers" route from webbrowser console when manually delete followers.

    Leave a comment:


  • lazovic
    replied
    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 Al​​l and myEntity permissions full access. Any help is wellcome!
Working...
X