Sunday, February 3, 2019

This is the first in hopefully a series of articles on incorporating useful functional programming techniques while writing JavaScript in ServiceNow.

How many times have you seen code like the following?

var grIncident = new GlideRecord('incident');
grIncident.addQuery('active=true^state=1');
grIncident.query();
while (grIncident.next()) {
    // do some processing with the GlideRecord
    gs.info('processing ' + grIncident.getDisplayValue());
}


This boilerplate code is so common in the platform, you probably use a code snippet or macro to type everything for you, then go back and edit as needed.

Any time you see the same code over and over, an alarm should go off in your head. You may have heard the about the DRY (Don't Repeat Yourself) principle. Why is it then, that we as ServiceNow developers violate this design principle virtually every day when we repeat this boilerplate code over and over again?

If you use such a code snippet, what are the things you end up going back to edit? Most likely they include the table name, query string and the processing to be done.

This gives us a hint to what things are fixed and what things change. In software design, the best practice is to separate the things that change from the things that remain the same. An example of this is using system properties to enable changes to code behavior without actually changing the code.

Can we write the GlideRecord query with looping logic in such a way that we separate the things we change each time from the boilerplate stuff that remains same?

Yes, we can, and it is the first step we'll take toward using a functional approach for our query logic. Here's a helper function named query that takes three parameters - the very three things we change after using a typical GlideRecord query code snippet:

function query(table, query, fn) {
    var gr = new GlideRecord(table);
    gr.addQuery(query);
    gr.query();
    while (gr.next()) {
        fn(gr);
    }
}

Here's an example of using our query helper to process new incidents:

function processNewIncident(grIncident) {
    gs.info('processing ' + grIncident.getDisplayValue());
    // do some processing with the GlideRecord
}

query('incident', 'active=true^state=1', processNewIncident);
Here's an example of re-using our helper function for something completely different:
function processClosedHighPriorityIncident(grIncident) {
    gs.info('processing ' + grIncident.getDisplayValue());
}

query('incident', 
    'active=false' + 
    '^ priority=1 ^OR priority=2', 
    processClosedHighPriorityIncident);

No more repeating boilerplate code, and by encapsulating our processing of an individual GlideRecord into a separate function, separating the processing concern from the data retrieval concern (another best practice - Separation of Concerns or SoC) our code becomes more readable and maintainable.

Monday, January 21, 2019

Access Control List

ACL(Access Control List):
An instance uses an access control list (ACL) rules, also called access control rules, to control what data users can access and how they can access it.(Simple meaning perform restriction of data) ACL rules require users to pass a set of requirements in order to gain access to particular data.
Each ACL rule specifies:
  • The object and operation being secured
  • The permissions required to access the object  

Record ACL rules:
Record ACL rules consist of table and field names.
  • The table name is the table that you want to secure. If other tables extend from this table, then the table is considered a parent table. ACL rules for parent tables apply to any table that extends the parent table.
  • The field name is the field that you want to secure. Some fields are part of multiple tables because of table extension. ACL rules for fields in a parent table apply to any table that extends the parent table.
ACL rules can secure the following record operations:
I m Defining  only for 4 Operation With Example:
Read: Allows users to display records from a table.
Write: Allows users to update records in a table.
Create: Allows users to insert new records (rows) into a table.
Delete: Allows users to remove records from a table or drop a table.
Record ACL rules are processed in the following order:
  • Match the object against table ACL rules.
  • Match the object against field ACL rules.
This processing order ensures that users gain access to more general objects before gaining access to more specific objects. A user must pass both table and field ACL rules to access a record object.
  • If a user fails a table ACL rule, the user is denied access to all fields in the table, even if the user passes a field ACL rule.
  • If a user passes a table ACL rule but fails a field ACL rule, the user cannot access the field described by the field ACL rule.
Table ACL Rule:
The user must first pass the table ACL rule. Since the base system includes STAR (*) table ACL rules that match every table, the user must always pass at least one table ACL rule. The base system provides additional table ACL rules to control access to specific tables.
Table ACL rules are processed in the following order:
  1. Match the table name. For example, incident.
  2. Match the parent table name. For example, task.
  3. Match any table name (*). For example, *.
If a user fails all table ACL rules, the user cannot access the fields in any table. If a user passes a table ACL rule, the system then evaluates the field ACL rules.
Field ACL Rule:
After a user passes a table ACL rule, field ACL rules are processed in the following order:
  1. Match the table and field name. For example, incident.number.
  2. Match the parent table and field name. For example, task.number.
  3. Match any table (*) and field name. For example, *.number.
  4. Match the table and any field (*). For example, incident.*.
  5. Match the parent table and any field (*). For example, task.*.
  6. Match any table (*) and any field (*). For example, *.*.
A user must pass the table ACL rule to be granted access to the table's fields. For example, the user must first pass the table ACL rule for the incident table to access the Number field in the incident table.
The first successful field ACL evaluation stops ACL rule processing at the field level. When a user passes a field ACL rule, the system stops searching for other matching field ACL rules. For example, if a user passes the field ACL rule for incident.number, the system stops searching for other ACL rules that secure the Number field in the incident table.

Define( None ,(*),Filed ):
These terms define through the example
Examples:


ServiceNow Interview Question


Java Scripting
  • • Difference between Client Script and Business Rule
  • • What is UI Script and give me any example where you used UI Script.
  • • D/B UI Policy and Data Policy?
  • • Difference between glide system and glide record.
  • • What is better alternative to using global business rule.
  • • Can a schedule job invoke an inactive business rule.
  • • Can we call a business rule from a client script
  • • What the setForceUpdate() function does?
  • • What is the significance of setLimit(n) function?
  • • Can you update a record without updating its system fields(like sys_updated_by, sys_updated_on)
  • • What is g_scratchpad and where we can use.
  • • In a UI policy, can we add gs.addinfomessage.
  • • Current.update() used on before or after business rule.
  • • What is ran on the client side and what is ran on the server side?
  • • How can you cancel a form submission through client script?
  • • What will happen if I make a client script 'global'.
  • • What is power shell script and where we are using.


Basic Configuration

  • • What is a Servicenow knowledge base?
  • • What is the sequencing of publishing a Knowledge Article?
  • • Where do you go in Service Now to change the banner and colors?
  • • What are the 3 basic components of workflow?
  • • What is BSM?
  • • How do you limit file attachments?
  • • What is the notification flow and how can a notification be sent out?
  • • What is the latest service now user interface and when it was released?
  • • What is dictionary override?
  • • What do you mean by coalesce?
  • • What happens when a user make some changes the homepage
  • • What is Schema map?
  • • What is a dashboard?
  • • What is dictionary override?
  • • When we publish a report, for whom is it available? Is it for everyone who has the URL.
  • • What do you understand by star (*) and none condition in ACL.
  • • What is an event queue? From where can it be called?
  • • Difference between Response and Resolution SLA.
  • • What is retroactive in SLA.
  • • How to enable multi-lingual in Service Now.
  • • What is wizard and interceptor in service now.
  • • What is generate task functionality in workflow.
  • • Give me an example where you used approval coordinator activity in workflow.
  • • What is domain separation?
  • • What among the following are domain independent – client script, business rule, schedule job, script include ?
  • • In workflow what is the difference between a timer and a wait for condition?
  • • What is difference between Order guide and Record Producer?
  • • What does the Client Transaction Timings plugin does?
  • • What is the life cycle of Release Management
  • • What is the life cycle of a CI or Asset ?
  • • What is watermark in notifications
  • • How to re-set the number counter.

Integrations
  • • What is LDAP Integration and its use?
  • • Which port needs to open while doing LDAP integration.
  • • What is the purpose of using SAML 2.0 (SSO)
  • • Pre-requisite to enable SSO (SAML 2.0)
  • • What is metadata in SAML 2.0
  • • What is keystore in SAML 2.0
  • • What is 509 x certificate in SAML 2.0
  • • What is difference between LDAP via MID server or LDAP via VPN Tunnel.
  • • What is E- Bonding ?
  • • Difference between SOAP and REST, and what is the purpose of using it.
  • • Which one is better in use SOAP or REST ?
  • • Which port need to be enable while doing SOAP and REST integrations.
  • • What is data source integrations. Any idea what kind of ports need to be open while doing SFTP, FTP integration.
  • • Have you worked on Email Inbound Integrations.
  • • How to check error handling while doing any integrations
  • • What kind of possibility if we get error code 401 or 404.
  • • If any transaction is successful what kind of success code we received ??
  • • Pre- requisite for enable Discovery plugin.
  • • What is props and sensors in Discovery.
  • • Difference between LDAP and LDAP's.
  • • Have you worked on SCCM integrations and what kind of data we discover from SCCM?
  • • What is transform script?
  • • What do you understand by Chasis Type in SCCM integrations?
  • • Have you worked on to install mid-server, if yes so what are all pre-requisite??
  • • What is Orchestration in service now, have you ever used and what kind of scripting language used in orchestration?
  • • What is the name of table in which we store relationship data of CI's.
  • • What is the table name which we expose as a web service to receive attachments in service now from any third part tool.
  • • What is payload in ecc queue ?

CMS
  • • What is drop zone in CMS .
  • • What is CMS and Why do use it .
  • • How we can configure multi- lingual home page in service now via CMS
  • • What is dynamic content in CMS.
  • • What is new came in CMS
  • • Have you ever used jelly in CMS.
  • • What is Service Portal?
  • • Have you worked on Angular JS?
  • • What is the benefit of using Angular JS.
  • • What is the difference between A JS and HTML?
  • • What is Page?
  • • What is Widget?
  • • What do we use in Page?
  • • What do u use in widget?
  • • What are directives?
  • • How will u call filter in AJS?
  • • What is ng-app?
  • • What is ng-init?
  • • What is ng-model?
  • • What is MVC?
  • • How will u use looop in AJS?



ITIL Knowledge
  • • If we used an external organization to help us develop part of our service, what would that be called?
  • • Can you name 3 types of SLA?
  • • Why would you use SACM?
  • • What is an OLA?
  • • What are the stages of the ITIL lifecycle(v3)?
  • • Release and Deployment Management is part of which phase?
  • • What are the parts of the Service Strategy?
  • • Change Management is part of which phase?
  • • What is the Difference between Utility and Warranty?
  • • What are different parts of service portfolio?
  • • What is the major difference between ITIL v2 and ITIL v3?

To understand what is Widget Dependency and how to create the dependencies

One of the best thing about ServiceNow is, it provides services with every possible functionality. And this goes same with Service Portal. ServiceNow ,Service Portal provides easy‑to‑use services that can be accessed from any device, any time.
So, Dependencies are loaded asynchronously from the server when needed.
In Service Portal, you can link JavaScript and CSS files to widgets to create dependencies between widgets and third-party libraries, external style sheets, and angular modules.Widgets can have as many or as few dependencies as needed. However, the more you add, the more content a widget must download to render on the page.
Note : Keep dependencies as small as possible for more efficient load times.
1. Create Dependency package
A dependency package is a collection of Javascript and CSS files that can be then connected to a widget.
In widget under the related list dependencies is visible, Dependencies Section consist of 3 fields

  • Name - The name of your dependency. (Useful for selecting a dependency from a dropdown list)
  • Include on page load - Select if you want your dependency to be loaded onto the page on initial page load of Service Portal, or leave unchecked to load the dependency only when the linked widget is loaded onto a page.
  • Angular module name - Optional. Define the value if the linked JavaScript is an Angular module. Provide the name of the Angular module being loaded, so that it can be injected into the Service Portal Angular application.
2.Add JS/CSS files to the dependency package
After you save the information for your dependency package,  
Include libraries into your dependency so that can be used by the widget by use of the related lists to ad JS and CSS Include files.
Basically there are two methods for creating a JS or CSS include.

  • URL
  • UI script (for a JS Include) or Style Sheet (for a CSS Include)

UI Script (JS/CSS Include)

Create a UI Script and refer it to the JS Include in the Widget Dependencies (Service Portal > Dependencies) under the related list. Under the JS Include related list add the UI script created.

Below it,
Using a CSS Stylesheet (CSS Include):
Same can be done by creating CSS Includes (same steps as JS Include). First create a CSS Style sheet by navigating to Service Portal > CSS .

Using a URL 
If want to add some Google Fonts, then go to the CSS Includes Related List within your Dependency and click New