Hi Dimitri, thank you for this!
I’m not technical enough to understand scripts but how is yours different from the one in here: Allow Rules/Formula Involving Rich-Text Fields - #14 by rothnic
That one uses a checkbox field “Detecting Description” and the script goes like this:
// Developer reference is at api.fibery.io/#action-buttons
// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');
// affected entities are stored in args.currentEntities;
// to support batch actions they always come in an array
for (const entity of args.currentEntities) {
// the rich text field is a document, which requires a special id to get access to
// In this case, the rich text field is "Description", so we request that field be included
const entityWithExtraFields = await fibery.getEntityById(entity.type, entity.id, ['Description']);
// as long as we have the rich text field looking valid, let's do something with it
if (entityWithExtraFields['Description']) {
// just saving a shorter reference to it
const dsc = entityWithExtraFields['Description'];
// get the rich text field contents as markdown (supports md, html, and json)
const doc = await fibery.getDocumentContent(dsc.secret, 'md');
// now we can search the rich text for whatever we are looking for
// In this case, lets just see if the doc is non-null and non-empty,
// then update a checkbox
const docExists = ((doc !== null) && (doc !== ''));
await fibery.updateEntity(entity.type, entity.id, {
'Detecting Description': docExists
});
}
}