- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 08:16 AM
I'm looking to create a BR to exclude file attachments with certain characters that get to sc_cart_item. It works but can I make this more specific so it only applies to specific catalog items?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2020 01:38 AM
Hi KB,
I have an idea for your problem statement. Please follow below steps and I think, this will work for selective catalog item.
- Create a script include with below details
Name: catalogAttachmentUtils
Client callable: True/checked
Script:
var catalogAttachmentUtils = Class.create();
catalogAttachmentUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
restrictAttachment: function() {
var cartID = this.getParameter("sysparm_restrictid");
gs.log(cartID, "cartID");
if (cartID)
gs.getSession().putClientData('catalog.attachment.restriction.id', cartID);
},
checkRestriction: function(id){
return (gs.getSession().getClientData('catalog.attachment.restriction.id').toString() == id.toString())?true:false;
},
type: 'catalogAttachmentUtils'
});
Client script
Name: Restrict Attachment
Type: Onload
Isolate script : false/ unchecked(this is very important, if not available on form, please add this field on form )
Script:
function onLoad() {
var cart_id = gel('sysparm_attachment_cart_id').value;
var ga = new GlideAjax('catalogAttachmentUtils');
ga.addParam('sysparm_name', 'restrictAttachment');
ga.addParam('sysparm_restrictid', cart_id);
ga.getXML(callbackFunction);
function callbackFunction(response) {
// just a placeholder
}
}
Finally, the business rule(on sys_attachment table with condition, table name = sc_cart_item) condition
new catalogAttachmentUtils().checkRestriction(current.table_sys_id)
Above steps will make sure, the business rule will only apply if, the catalog item has above onload script enabled.
Hopefully, this will work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 08:23 AM
Hi KB - You can apply filter condition in business rule i.e catalog item is | XYZ so that BR will only run for those Items.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 08:31 AM
Would I have to edit the BR to run off the cat item table instead of the attachment table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 10:52 AM
If the business rule is on attachment table then you can get the catalog item value via dot-walking script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2020 11:22 AM
Can you dotwalk from the attachment table when the item hasn't been submitted yet? There's nothing to reference the request item from there.