Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Who Me Too'd this topic

Avatar

Level 2

I am trying to run the following code to create content fragments programmatically. The code runs fine but there is no content fragment created in the DAM.

 

I am able to create the content fragments manually but not programmatically.

 

//Does not create a content fragment
Resource templateRes = resourceResolver.getResource("/conf/<projectname>/settings/dam/cfm/models/custom-model");
fragment = templateRes.adaptTo(FragmentTemplate.class).createFragment(parentFolder, "custom-name", "Custom Title");

// Asset gets created successfully.
AssetManager assetMgr = resourceResolver.adaptTo(AssetManager.class);
Resource resource = resourceResolver.getResource(parentFolder.getPath()+"/"+"test.jpeg");
Asset asset = assetMgr.createAsset(parentFolder.getPath()+"/"+"test.jpeg", null, "image/jpeg", true);

resourceResolver.commit();

 Any help is appreciated.

 

Thanks,

Nikunj Jariwala

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

Who Me Too'd this topic