Basic Questions in servicenow for CAD

RudhraKAM
Tera Guru

I am preparing for CAD , some questions are kind of confusing , can some one suggest the correct ans and some explanation please

1.

RudhraKAM_0-1687729883733.png

2.In a Business Rule, which one of the following returns true if the currently logged in user has the admin role?

 

1 ACCEPTED SOLUTION

Kalyani Jangam1
Mega Sage

Hi @RudhraKAM 

1. correct answer - Self Invoking

Self Invoking means -Self-invoking functions in JavaScript are the anonymous self-executing functions that are called after their definition. These JavaScript functions can run immediately when followed by the parentheses set (). This is self invoking template we used in business rule

 

for more details of self-invoking, please refer below link

https://linuxhint.com/self-invoking-functions-in-javascript/

 

2)In a Business Rule, which one of the following returns true if the currently logged in user has the admin role?

Correct answer- gs.hasRole('admin')

 

Please check and Mark Helpful or correct answer and let me know if any other help required for CAD Preparation

View solution in original post

4 REPLIES 4

Karan Chhabra6
Mega Sage

Hi @RudhraKAM ,

 

These type of functions are called ๐—œ๐—บ๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ๐˜๐—ฒ๐—น๐˜† ๐—œ๐—ป๐˜ƒ๐—ผ๐—ธ๐—ฒ๐—ฑ ๐—™๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป ๐—˜๐˜…๐—ฝ๐—ฟ๐—ฒ๐˜€๐˜€๐—ถ๐—ผ๐—ป (๐—œ๐—œ๐—™๐—˜) or self invoking functions

A function that is ๐—ถ๐—ป๐˜ƒ๐—ผ๐—ธ๐—ฒ๐—ฑ ๐—ถ๐—บ๐—บ๐—ฒ๐—ฑ๐—ถ๐—ฎ๐˜๐—ฒ๐—น๐˜† ๐—ฎ๐—ณ๐˜๐—ฒ๐—ฟ ๐—ถ๐˜ ๐—ถ๐˜€ ๐—ฐ๐—ฟ๐—ฒ๐—ฎ๐˜๐—ฒ๐—ฑ is called an IIFE, it is a stand-alone function with or without any name and no explicit invocation is required.

For invoking it, we simply ๐—ฎ๐—ฑ๐—ฑ (); ๐—ฎ๐—ณ๐˜๐—ฒ๐—ฟ ๐˜๐—ต๐—ฒ ๐—ฒ๐˜…๐—ฝ๐—ฟ๐—ฒ๐˜€๐˜€๐—ถ๐—ผ๐—ป, we can even pass arguments to it.

Every IIFE gets its ๐˜€๐—ฒ๐—ฝ๐—ฎ๐—ฟ๐—ฎ๐˜๐—ฒ ๐—ฒ๐˜…๐—ฒ๐—ฐ๐˜‚๐˜๐—ถ๐—ผ๐—ป ๐—ฐ๐—ผ๐—ป๐˜๐—ฒ๐˜…๐˜ - any variables or functions inside IIFE go into this execution context.

These variables are not in the global environment and even if any other variable or function exists with the same name - ๐˜๐—ต๐—ฒ๐˜† ๐—ฑ๐—ผ๐—ป'๐˜ ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐—ณ๐—ฒ๐—ฟ๐—ฒ ๐˜„๐—ถ๐˜๐—ต ๐—ฒ๐—ฎ๐—ฐ๐—ต ๐—ผ๐˜๐—ต๐—ฒ๐—ฟ. Variables and functions declared inside IIFE are ๐—ฝ๐—ฟ๐—ถ๐˜ƒ๐—ฎ๐˜๐—ฒ ๐—ฎ๐—ป๐—ฑ ๐—ถ๐—ป๐—ฎ๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐˜๐—ผ ๐˜๐—ต๐—ฒ ๐—ด๐—น๐—ผ๐—ฏ๐—ฎ๐—น ๐—ฒ๐—ป๐˜ƒ๐—ถ๐—ฟ๐—ผ๐—ป๐—บ๐—ฒ๐—ป๐˜.

 

Here, executeRule is a named IIFE with arguments current and previous.

 

Refer to these docs as well: https://developer.mozilla.org/en-US/docs/Glossary/IIFE

https://www.geeksforgeeks.org/immediately-invoked-function-expressions-iife-in-javascript/

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

Kalyani Jangam1
Mega Sage

Hi @RudhraKAM 

1. correct answer - Self Invoking

Self Invoking means -Self-invoking functions in JavaScript are the anonymous self-executing functions that are called after their definition. These JavaScript functions can run immediately when followed by the parentheses set (). This is self invoking template we used in business rule

 

for more details of self-invoking, please refer below link

https://linuxhint.com/self-invoking-functions-in-javascript/

 

2)In a Business Rule, which one of the following returns true if the currently logged in user has the admin role?

Correct answer- gs.hasRole('admin')

 

Please check and Mark Helpful or correct answer and let me know if any other help required for CAD Preparation

Thanks Kalyani ,What about the if the options have gs.hasRoleExactly(โ€˜adminโ€™) too ? which one we need to choose ?

Hi @RudhraKAM 

Please find difference of gs.hasRole() and gs.hasRoleExactly()

 

hasRole('itil') True if the current user has the role specified, false otherwise. ALWAYS returns true if the user has the 'admin' role. hasRoleExactly('itil') True if the current user has the exact role specified, false otherwise, regardless of 'admin' role.

 

Please Mark Helpful and Correct if it all information helpful.