Assets API returning unsaved CFs | Community
Skip to main content
August 22, 2022
Solved

Assets API returning unsaved CFs

  • August 22, 2022
  • 1 reply
  • 1214 views

Hi All,

 

I am using the assets API to return a list of Content Fragments. If this is called while someone has started to create a CF but hasn't saved it, the API returns the partial CF (e.g. an empty shell).

 

There is no saved date on the CF on the API so does anyone have any suggestions on how to overcome this please?

 

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Nikhil_Verma

No worries @aem_party , thanks for further explanation. I think I understand your use case now, but I also think we're not using the correct terminology ('saved') which is causing the confusion.

 

When a blank CF is created, it is in a 'saved' state.

Maybe what you're after are the CFs which are not empty? If thats the case then maybe you can look under the 'elements' property for a property (say, 'value' correpsonding to a CF field) if its empty or has a value.

 

Or maybe you are after the CFs that are not 'finalised' yet, meaning the author user is still working on it and hasn't finished writing it up. This would be tricky, as it more sounds like a business process rather than product. However I do see a property in CRX which seems to exists for a newly created CF only. But I don't see it in coming in assets API:

 

If you're lookiong for the CF that is published (which I suppose also indicates that the CF is 'finalised'), then you can look for the published property:

1 reply

Nikhil_Verma
August 23, 2022

I tried to reproduce the use case, but I'm able to get the create date of the content fragment. Below are my steps, let me know if any pf the steps are incorrect as per your use case:

 

1. Created a new blank content fragment called 'myCF1'.

 

2. No content is yet saved in the content fragment, and is currently empty:

 

3. Use asset API to get details of the content fragment:

http://localhost:4502/api/assets/myfolder/mycf1.json

The 'created' property is in epoch time.

AEM_PARTYAuthor
August 23, 2022

Thanks a lot for this.

 

Sorry, if I wasn't clear 🙂  The issue is I can't tell if the CF is saved or not. The created date doesn't confirm that the CF has been saved so there is no way to tell if this is a CF new and in the making or a saved one.

Nikhil_Verma
Nikhil_VermaAccepted solution
August 25, 2022

No worries @aem_party , thanks for further explanation. I think I understand your use case now, but I also think we're not using the correct terminology ('saved') which is causing the confusion.

 

When a blank CF is created, it is in a 'saved' state.

Maybe what you're after are the CFs which are not empty? If thats the case then maybe you can look under the 'elements' property for a property (say, 'value' correpsonding to a CF field) if its empty or has a value.

 

Or maybe you are after the CFs that are not 'finalised' yet, meaning the author user is still working on it and hasn't finished writing it up. This would be tricky, as it more sounds like a business process rather than product. However I do see a property in CRX which seems to exists for a newly created CF only. But I don't see it in coming in assets API:

 

If you're lookiong for the CF that is published (which I suppose also indicates that the CF is 'finalised'), then you can look for the published property: