- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 04:52 AM
I am preparing for CAD , some questions are kind of confusing , can some one suggest the correct ans and some explanation please
1.
2.In a Business Rule, which one of the following returns true if the currently logged in user has the admin role?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 05:43 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 05:23 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2023 05:43 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2023 09:22 AM
Thanks Kalyani ,What about the if the options have gs.hasRoleExactly(‘admin’) too ? which one we need to choose ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 01:44 AM
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.