Can I mass delete document type files?

I want to delete all files under type id “APCheck”, I have to delete each one and there are thousands of those file. How can I delete all?
Thanks

Have you tried to delete the files using the DMT?

5 Likes

You could do it with an Epicor Function:

/*
    In Library Reference, add the service ICE:BO:XFileRef

    request parameters:
        (System.Int32) BeginRefNum
        (System.Int32) EndRefNum
*/

CallService<Ice.Contracts.XFileRefSvcContract>( svc => {

    string whereClause = $"XFileRefNum >= {BeginRefNum} AND XFileRefNum <= {EndRefNum}";
    bool bMorePages;
    var tsXFileRefList = svc.GetList(whereClause, 1, 0, out bMorePages);

    foreach (var row in tsXFileRefList.XFileRefList)
    {
        svc.DeleteByID( row.XFileRefNum );
    }
});
1 Like

Those are in ECM, so I think removing the Xref will only take the reference out of Epicor, but not remove the file from ECM. I think it would be similar to what @kve posted, but using the AttachmentSvc or maybe you have to do both.

2 Likes

Run a trace on the screen and see what it’s calling.

I would imagine that screen does both, so you could just mimic that.

1 Like

If you delete using DMT, it should delete them from ECM. If you do it via the UI it does delete from ECM.

3 Likes

Yeah I should have thought of that. It will probably leave all the XFileAttach records intact, but with orphaned XFileRefNums

2 Likes