Category should be filled if a word is in the short description.

harshchaudh
Tera Contributor

Category should be filled if a word is in the short description. how can i solve such problem?

4 REPLIES 4

J Siva
Tera Sage
Tera Sage

Hi @harshchaudh 
Please elaborate on your requirement, and also share what you've done so far and where you're currently stuck.
Regards,
Siva

Rushi Savarkar
Kilo Sage
Kilo Sage

Hello @harshchaudh 

As per my understanding, the code will be below that you are looking for.

 

Business rule:

Before Insert/Update

 

(function executeRule(current, previous /*null rule when insert*/) {

    var shortDescription = current.short_description.toLowerCase(); 

    if (shortDescription.includes("printer")) {
        current.category = "Hardware";
    } else if (shortDescription.includes("email")) {
        current.category = "Software";
    } else if (shortDescription.includes("network")) {
        current.category = "Network";
    } else if (shortDescription.includes("password") || shortDescription.includes("account")) {
        current.category = "Access & Accounts";
    } else {
        // Set a default category or leave it blank if no match
        // current.category = "General Inquiry";
    }

})(current, previous);

Please let me know if it works.

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

Hello @harshchaudh 

Have you tried the above solution? 

If my response helped you, please accept the solution and mark it as helpful.
Thank You!

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @harshchaudh Let’s think practically. What you are looking for is a good use of Predictive Intelligence. For example, if the short description contains 'LAN', the category should be 'Hardware'. But what if the short description contains 'CLAN' or 'DLAN'? Also, when using search help, it checks for any alphabet combination. So, I would say your Predictive Intelligence needs to account for these variations.

*************************************************************************************************************
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]

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