Mass delete Files from records, but leave the records

Dear friends...

Any ideas on a way to mass delete files from records but to leave the record itself intact?

I actually thought I was doing this succesfully, but was deluding myself...  I use a report to ID the records I need, then from that report export do a textjoin to get a string of ID's, then use Postman to do the mass update using that string of ID's:

PUT {{url}}g_Registration/MassUpdate      (a custom module with file field: data-name="filename")

{  
    "massupdate_params": {
        "uid": [
            "a5ee304a-dd33-11ed-927f-0645eac4c674","ID2","ID3"...etc
        ],
    
       "filename" : ""
    }
}

But I now realise if I add a new filename

"filename" : "newFileName.pdf"

the actual file was still there! just with no name.

The Delete method: DELETE {{url}}g_Registration/MassUpdate... perfectly deletes the entire record.

So wondering if there is another way for a mere admin to achieve the same?
I was unable to use process definition to remove the file too.

If you work for Sugar and see this...  if only Data Archiver had some additional functionality to update a record? That'd be cool.

Thank for any tips...
Luke.

Parents
  • Hello  , 

    I was testing in the GUI and when deleting the file in Sugar this is the endpoint being hit: 

    So in postman I tried to hit this endpoint against my records: 

    DELETE  https://{MySugarURL}/rest/v11_23/ddd_Registrations/389c91e8-1924-11ef-aa6d-02a5a97c2d5e/file/uploadfile?delete_if_fails=true&platform=base

    And it seems to do the job.Only the file is deleted. 

    I've only tested a record individually, But if you have a .csv export you could set it up to import in postman and run it as a collection. 
    I've done something similar in the past, if you struggle implementing this let me know and I'll try find the collection that I used. 

    Let me know if this helps. 

    Cheers, 

    André 

Reply
  • Hello  , 

    I was testing in the GUI and when deleting the file in Sugar this is the endpoint being hit: 

    So in postman I tried to hit this endpoint against my records: 

    DELETE  https://{MySugarURL}/rest/v11_23/ddd_Registrations/389c91e8-1924-11ef-aa6d-02a5a97c2d5e/file/uploadfile?delete_if_fails=true&platform=base

    And it seems to do the job.Only the file is deleted. 

    I've only tested a record individually, But if you have a .csv export you could set it up to import in postman and run it as a collection. 
    I've done something similar in the past, if you struggle implementing this let me know and I'll try find the collection that I used. 

    Let me know if this helps. 

    Cheers, 

    André 

Children
  • Thank you  for your reply...
    I do use that endpoint from time to time...  but I had not figured how to use it for multiple records.

    So:  .csv export (yep, I have that from my report) to import in postman and run it as a collection.
    Aha... didn't know how to do that - will be my side job today Grinning

    Thank you for the top tip Andre, I will post my findings up here when done.

    For info, I need to do this as part of Storage Management - which does seem lacking in Sugar sadly.  So once in whatever timescale I hope to run my report, get the ID's into a string for postman (hopefully now using the collection method) ten delete all the proof of purchase files that until now we have stored indefinitely.  Just one part of a bigger project, But... if the collection thing works i can use that elswhere for other modules...

    Will keep this post posted...   Luke.
    (I am away from the office next week, so likely in a couple of weeks)