2sxc icon indicating copy to clipboard operation
2sxc copied to clipboard

[BUG] cms.run action - delete fails

Open enfJoao opened this issue 11 months ago • 6 comments

Bug Affects...

[x] JS development [x] Content Types or data management [x] APIs like REST

Current Behavior / Expected Behavior

Trying: $2sxc(111).cms.run({ action: 'delete', params: { entityId: 222 } }) But also tested all other variants of the command I could find.

All reproduce this error:

Image

Image

Image

This issue only seem to affect delete. All other actions work as intended. Tested user is host.

Your environment

  • 2sxc version(s): 19.03
  • DNN / Oqtane: DNN 9 and 10

enfJoao avatar Feb 09 '25 19:02 enfJoao

to me it seems like the message says the entity is in use. are you sure it's a bug in the API?

iJungleboy avatar Feb 18 '25 07:02 iJungleboy

Yes. Tested in a fresh app with a single entity type. No relations.

Also, check the "undefined" in the API request and the "Toolbar.Delete" in the message popup.

enfJoao avatar Feb 18 '25 08:02 enfJoao

I just did some tests and I believe delete works.

https://2sxc.org/dnn-tutorials/en/razor/tut/js-edit is a demo. Because of LightSpeed caching, you cannot see the effect (I have to figure out how to improve that), but on another site without caching it's clearly visible.

So I believe the API is working, but I do think that your entity is in use - probably on the module where you're seeing it.

I'm pretty sure if you go to admin and see the item, you'll see that it's in use once.

iJungleboy avatar Feb 18 '25 09:02 iJungleboy

Ok... A few notes:

  1. The item is clearly not being used anywhere. It's a blank app, a single content type, no relations anywhere.
  2. This tutorial pointing to the data API seems a completely different API from the cms.run.

I now tried this:

<script>
    function deleteItem(eID) {
        $2sxc(@MyContext.Module.Id).cms.run({ action: 'delete', params: { entityId: eID } });
    }
    function deleteItemNew(eID) {
        $2sxc(@MyContext.Module.Id).data('teste').delete(eID);
    }
</script>

deleteItem shows the error mentioned in the topic. deleteItemNew works as intended.

enfJoao avatar Feb 18 '25 12:02 enfJoao

now that's interesting, thanks for the follow up, will look into it.

iJungleboy avatar Feb 18 '25 13:02 iJungleboy

Perhaps related ?? For some reason it seems:

  1. I cannot delete items anymore I did something like : var toolbar = Kit.Toolbar.Empty().Edit().Remove().For(item).AsTag(); When I try to delete it says it will remove item undefined "[title of the item]" When I click OK it doest a DELETE request with a 400 (Bad request): https://websiteaddress/api/2sxc/app/auto/content/any/c5ac67c6-b17c-4464-a6aa-5228af2cf5b1?zoneId=2&appId=35 Saying it is probably still in use. Well it is, in this module but not anywhere else....

  2. the 'Remove' action is not showing. As an alternative, I tried: var toolbar = Kit.Toolbar.Empty().Edit().Remove().For(item).AsTag(); But the remove icon is not showing up, only an edit icon.

BondForWebSolutions avatar May 08 '25 09:05 BondForWebSolutions