The CreatorCon Call for Content is officially open! Get started here.

I want to send notification to the forms not particular item

mania
Tera Contributor

Hi,

This is the OOB notification, here It is sent to all the records but i want to sent this notification to all forms but except one particular catalog item form.

Can you please help on this, It will be usefull.

mania_0-1712745876524.png

Thanks!

10 REPLIES 10

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @mania 

May I know what is the use case here? 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

On RITM table, When a person is mentioned in work notes, an email notification will be sent to that person. ensure that work notes and user-visible comments do not cerate duplicate. - Here I want to send notification to all the tables but except one particular catalog item ex: catalog name is XYZ.

Here I have one oob notification is there Activity Stream @Mention Email, So this is send to all the forms/tables but i want to restrict that notification is not sent to that one particular catalog item which is XYZ.

Can you help on this, It will be usefull.

 

Thanks!

@mania 

You can modify the advance condition in the notification like below:

 

 

function shouldSend() {
    // Check if the current record's table is the catalog item table for XYZ
    if (current.table == 'catalog_item_table_name' && isCatalogItemXYZ(current.document)) {
        return false; // Exclude the notification for the catalog item XYZ
    }

    // Your existing logic for sending notifications
    var liveGroupProfileGR = new GlideRecord("live_group_profile");
    liveGroupProfileGR.setWorkflow(false);
    liveGroupProfileGR.addQuery("document", current.document);
    liveGroupProfileGR.addQuery("table", current.table);
    liveGroupProfileGR.addQuery("type", "!=", "support");
    liveGroupProfileGR.query();

    if(liveGroupProfileGR.next()) {
        var liveGroupMemberGR = new GlideRecord("live_group_member");
        liveGroupMemberGR.setWorkflow(false);
        liveGroupMemberGR.addQuery("group", liveGroupProfileGR.getUniqueValue());
        liveGroupMemberGR.addQuery("member", current.profile);
        liveGroupMemberGR.addQuery("state", "!=", "inactive");
        liveGroupMemberGR.query();

        if(liveGroupMemberGR.next()) {
            return false;
        }
    }

    var SecurityManager = new SNC.LiveFeedSecurityManager();
    return SecurityManager.canReadField(current.user, current.table, current.document, current.field_name);
}

// Check if the document associated with the notification is a catalog item for XYZ
function isCatalogItemXYZ(document) {
    var catalogItemGR = new GlideRecord('sc_cat_item'); // Assuming 'sc_cat_item' is the table name for catalog items
    if (catalogItemGR.get(document)) {
        // If a catalog item is found with the specified sys_id, check if it's for XYZ
        if (catalogItemGR.getValue('name') == 'XYZ') {
            return true; // The document is a catalog item for XYZ
        }
    }
    return false; // The document is not a catalog item for XYZ
}
shouldSend();

 

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks

mania
Tera Contributor

@Maddysunil 

 

I didnt get this completly.

 

Can you please tell me what is that current.document?

 

Thanks!