30 Use Case Scenario

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

30 Use case scenario

By- Sanika G Utekar

Use case 1: Whenever user selected on the Requested For, need to populate the manager and
Department of that user on corresponding variables.
Answer –
I have created a catalog with 3 variables as below.
a. Requested For(Reference -sys_user)
b. Manager
c. Department
Use case 2: Check if the current time is greater than start date time and smaller than end date
time. If start date is greater than end date add error message

Answer

a. Created field in incident table as start date and end date

b create client script with adding query


Here is the syntax

function onLoad() {
//Type appropriate comment here, and begin script below
var start = g_form.getValue('u_start_date');
var end = g_form.getValue('u_end_date');

if(start > end )


{
g_form.addErrorMessage('date cannot be insert');
return false;
}
}
Use case 3: Create an Ui action button by name ‘closed’ on incident table. When you click on
the button the state will automatically closed. With a confirming message

Answer

Here is the syntax-


function setClosed() {

g_form.setValue('state', 7);
g_form.setValue('close_code', 'Resolved by request');
g_form.setValue('close_notes', 1);
confirm('are you sure');
}
After clicking on closed button the confirm action will he shown first and then state will be
closed with resolution and notes
Use case 4 : On incident table update ‘short description ’ and ‘description’ field when the
category is software and state is closed .

Approach-

// This scenario can be achieved by both background as well as Fix script .

Here I will approach it with Fix script. created new fix script with name Test_script

Here is the syntax -

var gr= new GlideRecord ('incident');


gr.addEncodedQuery('category=software^state=7')
gr.query();
while(gr.next()){
gr.short_description = 'This is closed incident, confirm with
manager';
gr.description= "hello sanika, confirm with team";
gr.update();
gs.print('this is incident number'+' '+gr.number)
}
Output Shown as below-
Use case 5 : On Change of Caller I want short description field to be written as “on change of
caller “ and send alert message ‘this is because of change in caller’ + incident from number.

Approach –

I will achieve this with help of on change function of client script on category field.

Once change in caller_ id we can achieve above use case. As below image

Below is the image of alert message populated when the condition is matched

Here is the syntax of client script


function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//Type appropriate comment here, and begin script below


alert('this is because of caller id in category' +' '
+g_form.getValue('number'));
g_form.setValue('short_description','on change of caller person ');
Here is the ss of client script
Use case 6 :How to show inactive incidents to only ITIL admins and hide for all other users,
explain different ways to achieve this?

Approach –

We can achieve this by elevating our role and creating Acl and marking Active is false for
incident table.

There are two approaches to implement this scenario :

Method 1 : Using ACL


After impersonating ‘itil ‘ user this is how itil user incident will look:-

Use case 7 :Create list of incident created today , while using setlimit function ate set
row count.
Use case 8 : IF priority is 1 on incident form alert with a flash .

Approach:

We can achieve this with help of client script .

Here is the syntax

function onLoad() {
//Type appropriate comment here, and begin script
below
if(g_form.getValue('priority')==1);{
g_form.flash('priority',"#FFFACD",-10)
}
}
Use case 9: create an incident record using flow designer when the priority is critical

Also add value to short description, description caller and assigned to.
Here is the final record formed through incident.

Use case 10: Create Field "Point of Failure" Drop down


1.Internal to Core Network
2. External before
3. External at or after
4.if 2 or 3 is chosen from the "Point of Failure" field a new drop down box should show under
the Point of Failure called "External Location" that is Required

Approach –

Here we have to use incident and business rule.

1. create a drop field with given choice option


2. Create choice in that option

3. Create a ui policy to match 4th condition.


When the point of table is Internal to Core Network it doesn’t show the External Location field

But when it is chosen as2. External before or 3. External at or after . it wil be shown

here is the full image


Use case 11: Create a change record when incident record is created ?

Approch-

Here 1st create a business rule by name incident to change. As below

Her is the syntax-

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

// Add your code here


var change = new GlideRecord('change_request');
change.description = current.description;
change.caller_id = current.caller_id;
change.short_description = current.short_description;
change.impact = current.impact;
change.insert();
gs.addInfoMessage('this is the number of change record' + ' ' +
change.number);

})(current, previous);

Then create an incident record and save it.


In change request table will look like this.
Use case 12: Attach sla to incident form when priority is set to be 1

SET SLA Condition

Sla with priority 1 condition attached to incident

Use case 13: create a report to fetch the average count of the incidents created last for the last year.
Use case 13: Using Background script I need to create 10 incident records in incident table?

Here is the background script, and calle sys_id is of Abel tutor

Here is the code

for(var i = 0 ; i < 10 ; i++)

{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = '62826bf03710200044e0bfc8bcbe5df1';
gr.insert();
}

And following is output


Use case 14:Create a reporton incident created 7 days ago, whose active is true.
Use case 15:Alert VIP caller based on impact and urgency

Here is the code-

var caller = g_form.getReference('caller_id', getvip);

}
function getvip(caller) {

if (caller.vip)

g_form.setValue('urgency','1');

g_form.setValue('impact','2');

Use case 16: Make assignment group and assigned to fields editable only to admin and
incident manager. For others, these fields should be read-only
Answer:-
Write a Client Script:-

function onLoad(){
if(!g_user.hasRoleExactly('admin') || !g_user.hasRoleExactly('incident_manager')){
g_form.setReadOnly('assignment_group', true);
g_form.setReadOnly('assigned_to', true);
}
}

Use case 17: There should be at least one incident, task associate, with an incident when state
becomes work in progress and resolved.
Answer:-
Write BR for that:-
Condition: State [Changes To] Work In Progress or Resolved
Script:-

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


// Add your code here
var incTask = new GlideRecord('incident_task');
incTask.addQuery('parent', current.sys_id);
incTask.query();
if(!incTask.next()){
gs.addErrorMessage('Not allowed');
current.setAbortAction(true);
}
})(current, previous);
Use case 18: :-Problem related to the incident should get displayed in a related list on the
incident.
Answer:-
Need to create defined relationships
Navigate to Relationship
Applies to Table - incident
Queries from the table - problem
Script:-

(function refineQuery(current, parent) {


// Add your code here, such as current.addQuery(field, value);
current.addQuery('sys_id', parent.problem_id);
})(current, parent);
Use case 19: How to show all incidents opened by the same caller as related list on incident
records?

We can create view rules to change view based on some conditions. Below view rules can be
used to show view for new records and existing records on incident table.

This is the View Rule for new records on incident table. For testing purpose 'Cxs_popup' view
has been configured for new records. Since 'Created date' is empty for new records so we can
use this condition to identify if opened record is new or not:

This to show all incident with same caller as that of current incident :
For more details about relations

Use case 20: how can you execute activites/action/task parallely in flow designer?

We
can
use
flow

logic "Do the following in parallel" this lets us execute multiple set of flow actions parallely.
Use case 21: Create a new field Date and add validation for the date field so that it takes only
future date.
Answer:-
Config-Form Design-Add date field
Navigate to UI policy:-

Script Section:-
Execute If true:-
function onCondition(){
g_form.setValue('date',' ');
alert('Enter Valid Date, It cannot be past date');
}

Use case 22 create fix script showing incident record when category is software and state is
closed.
ar gr= new GlideRecord ('incident');

gr.addEncodedQuery('category=software^state=7')
gr.query();
while(gr.next()){
gr.short_description = 'This is closed incident, confirm with manager';
gr.description= "hello sanika, confirm with team";
gr.update();
gs.print('this is incident number'+' '+gr.number)
}

Use case 23:

Requirement: When creating a new problem task from Problem view i want to populate few
fields of problem into the problem task such as Assignment group, Assigned to, problem
statement.
So For this, we will create a Display BR on the problem_task table. The Display Br executes
whenever we view a record on the problem_task.
Display BR
System Definition -> Business Rules ->New
Table: Problem_task
conditions: Parent is not empty (So that this BR runs only when click on new from existing
problem)
Under Advanced, in the script add this code
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("problem");
if (gr.get(current.parent)) {
g_scratchpad.parent=current.parent;
g_scratchpad.short_description=gr.short_description;
g_scratchpad.assigned_to=gr.assigned_to;
g_scratchpad.assignment_group=gr.assignment_group;
}
})(current, previous);

Save the BR.


Then create a onLoad client script and there you will have access to g_scratchpad object and
populate the values into the problem_task form.
Client Script
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_scratchpad.parent) {
g_form.setValue("short_description",g_scratchpad.short_description);
g_form.setValue("assignment_group",g_scratchpad.assignment_group);
g_form.setValue("assigned_to",g_scratchpad.assigned_to);
}
}
Use case 24: How to show inactive incidents to only ITIL admins and hide for all other users
using Business Rule.
Using Before Query BR

- Write before query BR as shown below, it checks if logged in user has ITIL admin role or not. If user has ITIL
admin role then inactive incident will be shown otherwise it will be hidden.

BR Configuration

BR Script
:
Use case 25: create two reports below:
Need to create:
1. Report showing the no. of all catalog items
2. Report showing the no. of catalog items marked as favorites.
.
1. Report showing no. of all catalog items:

2. Report showing no. of catalog items marked as favorites (report on Favorite (App Use) sn_ex_sp_st_favorite
table where Category is Request):

Use case 26: write a script to show incident count for each state which are updated today?

We can use GlideAggregate API to achieve this scenario:

Script :
gs.print('State\\tIncident Count');

var grIncident=new GlideAggregate('incident');


grIncident.addEncodedQuery(' sys_updated_onONToday@javascript:
gs.beginningOfToday()@javascript: gs.endOfToday()');
grIncident.addAggregate('COUNT','state');
grIncident.query();
while(grIncident.next()){
gs.print(grIncident.state. getDisplayValue()+'\t'+grIncident.
getAggregate('COUNT','state'));
}
Output :

Use case 27: How to show specific view while creating new record and different view for
existing record?

We can create view rules to change view based on some conditions. Below view rules can be
used to show view for new records and existing records on incident table.

This is the View Rule for new records on incident table. For testing purpose 'Cxs_popup' view
has been configured for new records. Since 'Created date' is empty for new records so we can
use this condition to identify if opened record is new or not:

Result :
This is the View Rule for existing records on incident table. For testing purpose 'ess'(self
service) view has been configured for existing records. Since 'Created date' is not empty for
existing records so we can use this condition to identify if opened record is existing record: :

Result :
Use case 28: Create an knowledge article of any article of your choice.
Approach- create a knowledge base article on event management application.

Once done publish it and approve by an approver

Once it approved it will show publish as following:


then go to knowledge bases>

here is the output:


Use case 29: create a common script for emails that will contain INC number, short description,
Priority and configuration item:-
Answer:-

Create Email Script.


Create Notification.
Add mail script template in notification body by using:-

${mail_script:script name}

Script:-

Use case 30:

There should be at least one incident, task associate, with an incident when state becomes
work in progress and resolved.
Answer:-
Write BR for that:-
Condition: State [Changes To] Work In Progress or Resolved
Script:-

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


// Add your code here
var incTask = new GlideRecord('incident_task');
incTask.addQuery('parent', current.sys_id);
incTask.query();
if(!incTask.next()){
gs.addErrorMessage('Not allowed');
current.setAbortAction(true);
}
})(current, previous);

Thankyou - 

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy