Make category, description,meta and picture mandatory on newly creating catalog items.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Currently when a new catalog item is requested, the category,detailed description and meta,picture are optional. Going forward it should not be like that without affecting existing catalog items ,how can we proceed with system ui policy or onsubmit client scripts,or any business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
Hi @BalimeniP
I'd avoid making these fields mandatory at dictionary level, because that would affect existing catalog items (and any update or import of them). Instead:
- Business rule (the main control, server-side)
Table: sc_cat_item, When: before, Insert: true (and Update: true if you also want to enforce it on activation, see the note below).
(function executeRule(current, previous) {
var missing = [];
if (current.category.nil()) missing.push('Category');
if (current.description.nil()) missing.push('Description');
if (current.meta.nil()) missing.push('Meta');
if (current.picture.nil()) missing.push('Picture');
if (missing.length) {
gs.addErrorMessage('Please populate: ' + missing.join(', '));
current.setAbortAction(true);
}
})(current, previous);Use the condition "current.isNewRecord()" (or simply only tick Insert), so existing items aren't affected. If you'd rather enforce it when an item goes live, use the condition "Active changes to true" instead.
- onLoad client script (for user experience)
Table: sc_cat_item
function onLoad() {
if (g_form.isNewRecord()) {
g_form.setMandatory('category', true);
g_form.setMandatory('description', true);
g_form.setMandatory('meta', true);
g_form.setMandatory('picture', true);
}
}If this helped, please mark it as the accepted solution so others with the same question can find it.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago