Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Server-Side Components/Business Rules/DateDifference.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function executeRule(current, previous /*null when async*/) {

// Add your code here
if(current.u_termination_date.changes()){
var date1=current.u_current_date;
var date2=current.u_termination_date;

var res=onDemand1(date1,date2);
gs.addInfoMessage("Date Difference is :"+res);

}
})(current, previous);
14 changes: 14 additions & 0 deletions Server-Side Components/Business Rules/MyFolder/CreateProblem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function executeRule(current, previous /*null when async*/) {

// Add your code here
if(current.category == 'hardware'){
var gr=new GlideRecord('problem');
gr.initialize();
gr.short_description=current.short_description;
gr.category=current.category;
gr.impact=current.impact;
gr.urgency=current.urgency;
gr.insert();

}
})(current, previous);
2 changes: 2 additions & 0 deletions Server-Side Components/Business Rules/MyFolder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This script is a ServiceNow Business Rule that automatically creates a Problem record whenever an Incident is created with the category set to "hardware".
It helps in ensuring that hardware-related incidents are tracked and analyzed properly through Problem Management.
16 changes: 16 additions & 0 deletions Server-Side Components/Business Rules/ProblemCount.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


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

var problemSysId = current.sys_id;
var agg = new GlideAggregate('incident');
agg.addQuery('problem_id', problemSysId);
agg.addAggregate('COUNT');
agg.query();

if (agg.next()) {
var incidentCount = agg.getAggregate('COUNT');
gs.addInfoMessage('There are ' + incidentCount + ' incidents related to this problem.');
}

})(current, previous);
Loading