30 Use Case Scenario
30 Use Case Scenario
30 Use Case Scenario
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
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');
Answer
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-
Here I will approach it with Fix script. created new fix script with name Test_script
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
Approach –
We can achieve this by elevating our role and creating Acl and marking Active is false for
incident table.
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:
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.
Approach –
But when it is chosen as2. External before or 3. External at or after . it wil be shown
Approch-
})(current, previous);
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?
{
var gr = new GlideRecord('incident');
gr.initialize();
gr.caller_id = '62826bf03710200044e0bfc8bcbe5df1';
gr.insert();
}
}
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:-
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)
}
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);
- 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?
Script :
gs.print('State\\tIncident Count');
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.
${mail_script:script name}
Script:-
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:-
Thankyou -