Power of Scripting - JavaScript Use Cases
- Enterprise IT
- Mayuresh Balaji Kamble (Unlicensed)
What is Scripting?
With new Scripting option available on all the pages of the SummitAI application (Alps), the Administrators can now write their own JavaScript, HTML, and CSS codes to customize the fields available on these pages.
SummitAI - Version
Scripting feature is introduced into the SummitAI application on few pages with the Alps release. This feature is now available on all the pages of the Application with Alps SP1 release. In the Alps release, the Admin could write JavaScript and CSS codes. With Alps SP1 release, the Administrators can write JavaScript, HTML, and CSS codes.
For more information about Scripting, see Scripting.
Why Scripting?
Scripting gives the power to the Administrators to write their own codes to make changes the way the organizations want.
The SummitAI R&D team can help the organizations in writing codes and can provide solutions to the customer requirements much faster instead of waiting for longer release cycles.
The JavaScript codes are executed only to the specific customer instance. No product code change is required eliminating the need to plan, develop, and test the changes.
The SummitAI team can focus on other customer requirements and product roadmap features instead of spending time on UI changes, which can be now easily achieved with Scripting.
Use Cases for JavaScript
How to Inspect Elements to Find Controls?
This section provides instructions to inspect an element in the following browsers:
Microsoft Edge
To inspect elements in Microsoft Edge:
- Hover over the element to inspect and then press F12.
or
Click the icon (present on the top right-hand corner of the browser) > Click Developer Tools.
- On the Inspect window, click the icon (Select the Element icon)..
- Take the mouse cursor to the element you want to inspect click the element. The ID of the element is displayed in the Inspect window.
Internet Explorer
To inspect elements in Internet Explorer:
- Hover over the element to inspect and then press F12.
or
Click the icon (present on the top right-hand corner of the browser) > Click F12 Developer Tools.
- On the Inspect window, click the icon (Select Element icon).
- Take the mouse cursor to the element you want to inspect click the element . The ID of the element is displayed in the Inspect window.
Firefox
To inspect elements in Firefox:
- Hover over the element to inspect and then press F12.
or
Click the icon (present on the top right-hand corner of the browser) > Click Web Developer > Storage Inspector.
- On the Inspect window, click the icon (Select Element icon).
- Take the mouse cursor to the element you want to inspect. The ID of the element is displayed in the Inspect window.
Google Chrome
To inspect elements in Google Chrome:
- Hover over the element to inspect and then press F12.
or
Click the icon (present on the top right-hand corner of the browser) > Click More Tools > ClickDeveloper Tools.
- On the Inspect window, click the icon
- Take the mouse cursor to the element you want to inspect. The ID of the element is displayed in the Inspect window.
Below example shows how to inspect element in Google Chrome :-
Use Cases - Details
Following are the various use cases where SummitAI has leveraged on the Scripting functionality and delivered various customer customizations
Note:
Code samples are provided for few of the use cases. For the other JavaScript codes, please contact SummitAI Support.
Use Case #1: The Analyst should enter a business justification if the Change is not implemented as per the schedule
Page: Change > New Change Record
Prerequisite: Create a custom field called "Business Justification"
JavaScript Logic: If there is a difference between "Planned Start Date/ Planned End Date" and "Actual Start Date/ Actual End Date", the custom field "Business Justification" will become mandatory when the Change Record status is Implemented.
function CMChangeRequestCustomOnSaveJS() {
//place custom validation script here
//return false if you dont want to submit the changes
if (!fnDateValidationJS()) {
return false;
}
return true;
}
//***compared between planned start time & actual start time****//
fnDateValidationJS();
function fnDateValidationJS() {
try {
var lblPlannedstarttime = 'BodyContentPlaceHolder_lPlannedStartTime1',
datPlannedstarttime = 'BodyContentPlaceHolder_txtPlanStartRlease_Time',
lblPlannedendtime = 'BodyContentPlaceHolder_lPlannedEndTime1',
datPlannedendtime = 'BodyContentPlaceHolder_txtPlan_End_Rlease_Time',
lblActualstarttime = 'BodyContentPlaceHolder_lActualStartTime1',
datActualstarttime = 'BodyContentPlaceHolder_txtActualStartTime',
lblActualendtime = 'BodyContentPlaceHolder_lActualEndTime1',
datActualendtime = 'BodyContentPlaceHolder_txtActual_End_Time_Release',
lblJustification = 'BodyContentPlaceHolder_lblCF_49',
txtJustification = 'txt_49';
lblPlannedstarttime = $('#' + lblPlannedstarttime);
datPlannedstarttime = $('#' + datPlannedstarttime);
lblPlannedendtime = $('#' + lblPlannedendtime);
datPlannedendtime = $('#' + datPlannedendtime);
lblActualstarttime = $('#' + lblActualstarttime);
datActualstarttime = $('#' + datActualstarttime);
lblActualendtime = $('#' + lblActualendtime);
datActualendtime = $('#' + datActualendtime);
lblJustification = $('#' + lblJustification);
txtJustification = $('#' + txtJustification);
lblJustification.hide();
txtJustification.hide();
if (datPlannedstarttime.val().trim().length > 0 && datActualstarttime.val().trim().length > 0) {
if (Date.parse($("#BodyContentPlaceHolder_txtPlanStartRlease_Time").val()) != Date.parse($("#BodyContentPlaceHolder_txtActualStartTime").val())) {
lblJustification.show();
txtJustification.show();
lblJustification.addClass('mandatoryField');
MarkRequiredInputs();
if (txtJustification.val().trim().length == 0) {
InitOnScreenNotification("specify " + lblJustification.text().replace('*', ''), 'warning');
return false;
}
}
}
if (datPlannedendtime.val().trim().length > 0 && datActualendtime.val().trim().length > 0) {
if (Date.parse($("#BodyContentPlaceHolder_txtPlan_End_Rlease_Time").val()) != Date.parse($("#BodyContentPlaceHolder_txtActual_End_Time_Release").val())) {
lblJustification.show();
txtJustification.show();
lblJustification.addClass('mandatoryField');
MarkRequiredInputs();
if (txtJustification.val().trim().length == 0) {
InitOnScreenNotification("specify " + lblJustification.text().replace('*', ''), 'warning');
return false;
}
}
}
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
return true;
}
$("#BodyContentPlaceHolder_txtPlanStartRlease_Time, #BodyContentPlaceHolder_txtActualStartTime").change(function () {
fnDateValidationJS();
});
$("#BodyContentPlaceHolder_txtPlan_End_Rlease_Time, #BodyContentPlaceHolder_txtActual_End_Time_Release").change(function () {
fnDateValidationJS();
});
Use Case #2: When an Analyst logs an Incident for an End User, the Application should prompt if an open Incident exists for that user under the same Category. This would prevent the Analyst from creating duplicate Incidents for the same user .
Page: Incident > New Incident for User
JavaScript Logic: Based on the Caller and the Category of the Incident, validate if there is any open Incident for that Caller under the same Category. Display a popup, which indicates that there are open Incidents for that caller under the same Category. Display the Incident IDs in the popup.
function LogNewTicketCustomOnSaveJS() {
var InstanceCtrl = $('#BodyContentPlaceHolder_UCInstanceList_lstInstance');
if (InstanceCtrl.val() == 'DLPL') {
if(!isTicketExists_Summit())
return false;
}
return true;
}
function isTicketExists_Summit() {
var status = false;
try {
var CallerID1 = $('#BodyContentPlaceHolder_txtCaller'); // Caller Textbox ID
var hdnCallerID = $('#BodyContentPlaceHolder_hdnCallerID'); // Caller hidden field ID
var hdnCategoryID = $('#BodyContentPlaceHolder_hdnCategoryID'); // Category hidden Field ID
var Instance1 = $('#BodyContentPlaceHolder_UCInstanceList_lstInstance'); // Instance Control ID
var validationMsg = 'Already few open incidents are there under this category.'; //Validation Message
var CustomAttributeNameID = $('#txt_23'); // Customer Attribute control ID
//var CustomAttributeNameID = $('#txt_1170');
var CustomAttributeID = 23; // Custom Attribute ID if customattribute control id is #cddl_109, 109 is attribute ID
var Selectedcategory, selectedcustAttribute, SelectedInstance;
var Tickets = null;
var Counts = 0;
var IncidentRaiseStatus; var Caller_ID = 0;
// if caller control enabled in lognew incident check is enabled if enabled need to take caller otherwise Log in user
if (CallerID1.length == 1) {
var callerid = hdnCallerID.val();
if (callerid != undefined && callerid != "" && callerid != null) {
Caller_ID = hdnCallerID.val();
}
else {
Caller_ID = UserID;
}
}
else {
Caller_ID = UserID;
}
console.log(Caller_ID);
Selectedcategory = hdnCategoryID.val();
selectedcustAttribute = CustomAttributeNameID.val();
SelectedInstance = Instance1.val();
/*
* URL,User Name and password need to change
* dynamic service name should be "Is_Category_TicketExists"
*/
if (Caller_ID > 0 && Selectedcategory != null && Selectedcategory != "" && SelectedInstance != null && SelectedInstance != "") {
var settings = {
"async": false,
"crossDomain": true,
"url": "http://52.172.217.125/API/REST/Summit_RESTWCF.svc/RESTService/CommonWS_JsonObjCall",
"method": "POST",
"dataType": "json",
"contentType": "application/json",
"headers": {
"content-type": "application/json"
},
"processData": false,
"data": "{\"ServiceName\":\"ADM_Get_DynamicWebServiceResult\",\"objCommonParameters\":{\"_ProxyDetails\":{\"Password\":\"admin@123\",\"UserName\":\"summitadmin@dlpl.com\",\"ProxyID\":0,\"ReturnType\":\"JSON\",\"OrgID\":1},\"ServiceName\":\"Is_Category_TicketExists\",\"objDynamicWebService\":{\"InputString\":\"{\\\"CustomeAttributeID\\\":\\\"" + CustomAttributeID + "\\\",\\\"categoryId\\\":\\\"" + Selectedcategory + "\\\",\\\"userID\\\":\\\"" + Caller_ID + "\\\",\\\"instance\\\":\\\"" + SelectedInstance + "\\\",\\\"CustomeAttributeValue\\\":\\\"" + selectedcustAttribute + "\\\"}\"}}}"
}
var Isexiststicket = $.ajax(settings).done(function (response) {
if (response) {
result = response;
if (result.OutputObject != null && result.OutputObject.SUBROOT[0] != null) {
IncidentRaiseStatus = result.OutputObject.SUBROOT[0].IsTicket_Exists;
Counts = result.OutputObject.SUBROOT[0].Counts;
Tickets = result.OutputObject.SUBROOT[0].Tickets;
console.log(IncidentRaiseStatus, Counts, Tickets);
console.log('got the response');
}
if (IncidentRaiseStatus != undefined && IncidentRaiseStatus == "0") {
status = true;
console.log('status is true');
}
else if (IncidentRaiseStatus != undefined && IncidentRaiseStatus > 0) {
status = false;
}
else if (IncidentRaiseStatus == undefined) {
status = false;
console.log('IncidentRaiseStatus is undefined');
}
if (status == false) {
InitOnScreenNotification(validationMsg + '<br> : ' + Tickets, 'validationmsg');
console.log('status is false');
status = false;
}
}
}).fail(function (response, err) {
console.log("fail block");
console.log(response);
console.log(err);
status = false;
}).always(function () {
console.log("Completed");
})
}
else {
console.log('else block variables null');
InitOnScreenNotification('Please enter required data', 'validationmsg');
status = false;
}
}
catch (e) {
status = false;
console.log("catch block");
console.log(e.message);
console.log("error occured isTicketExists()");
}
return status;
}
Use Case #3: The 'Service Window' field on the Incident details page should be hidden for the Analysts. The Analysts should not change the Service Window of the Incidents.
Page: Incident > Incident List > Select Incident
JavaScript Logic: Disable (Freeze) the Service Window field if an Analyst has logged in.
$(document).ready(function () {
$('#BodyContentPlaceHolder_ddlSLA').prop('disabled', true);
var UserID = getCallerID();
debugger;
var settings = {
"async": false,
"crossDomain": true,
"url": "http://localhost/SummitWS/REST/Summit_RESTWCF.svc/RESTService/CommonWS_JsonObjCall",
"method": "POST",
"headers": {
"content-type": "application/json"
},
"processData": false,
"data": "{\"ServiceName\":\"ADM_Get_DynamicWebServiceResult\",\"objCommonParameters\":{\"_ProxyDetails\":{\"Password\":\"test@123\",\"UserName\":\"honnambika.m@symphonysummit.com\",\"ProxyID\":0,\"ReturnType\":\"JSON\",\"OrgID\":1},\"ServiceName\":\"IM_CheckAdmin\",\"objDynamicWebService\":{\"InputString\":\"{\\\"UserID\\\":\\\"" + UserID + "\\\"}\"}}}"
}
var Isexiststicket = $.ajax(settings).done(function (response) {
if (response) {
result = JSON.parse(response);
if (result.OutputObject.SUBROOT != "") {
if (result.OutputObject.SUBROOT[0].Column1 == 1) {
$('#BodyContentPlaceHolder_ddlSLA').prop('disabled', false);
}
}
}
}).fail(function (response, err) {
console.log("fail block");
console.log(response);
console.log(err);
status = false;
}).always(function () {
console.log("Completed");
})
});
Use Case #4: The Child Change Record Category should be selected before submitting a Change Record.
Page: Change > Change Record List > Select CR
JavaScript Logic: Validate if the Child Category is selected. If the Analyst has not selected the Child Category, display a pop up message indicating that the Child Category should be selected, and do not allow the Analyst to submit the CR without selecting the Child Category of the CR.
function LogNewTicketCustomOnSaveJS() {
var InstanceCtrl = $('#BodyContentPlaceHolder_UCInstanceList_lstInstance');
if (InstanceCtrl.val() == 'DLPL') {
if(!isTicketExists_Summit())
return false;
}
return true;
}
function isTicketExists_Summit() {
var status = false;
try {
var CallerID1 = $('#BodyContentPlaceHolder_txtCaller'); // Caller Textbox ID
var hdnCallerID = $('#BodyContentPlaceHolder_hdnCallerID'); // Caller hidden field ID
var hdnCategoryID = $('#BodyContentPlaceHolder_hdnCategoryID'); // Category hidden Field ID
var Instance1 = $('#BodyContentPlaceHolder_UCInstanceList_lstInstance'); // Instance Control ID
var validationMsg = 'Already few open incidents are there under this category.'; //Validation Message
var CustomAttributeNameID = $('#txt_23'); // Customer Attribute control ID
//var CustomAttributeNameID = $('#txt_1170');
var CustomAttributeID = 23; // Custom Attribute ID if customattribute control id is #cddl_109, 109 is attribute ID
var Selectedcategory, selectedcustAttribute, SelectedInstance;
var Tickets = null;
var Counts = 0;
var IncidentRaiseStatus; var Caller_ID = 0;
// if caller control enabled in lognew incident check is enabled if enabled need to take caller otherwise Log in user
if (CallerID1.length == 1) {
var callerid = hdnCallerID.val();
if (callerid != undefined && callerid != "" && callerid != null) {
Caller_ID = hdnCallerID.val();
}
else {
Caller_ID = UserID;
}
}
else {
Caller_ID = UserID;
}
console.log(Caller_ID);
Selectedcategory = hdnCategoryID.val();
selectedcustAttribute = CustomAttributeNameID.val();
SelectedInstance = Instance1.val();
/*
* URL,User Name and password need to change
* dynamic service name should be "Is_Category_TicketExists"
*/
if (Caller_ID > 0 && Selectedcategory != null && Selectedcategory != "" && SelectedInstance != null && SelectedInstance != "") {
var settings = {
"async": false,
"crossDomain": true,
"url": "http://52.172.217.125/API/REST/Summit_RESTWCF.svc/RESTService/CommonWS_JsonObjCall",
"method": "POST",
"dataType": "json",
"contentType": "application/json",
"headers": {
"content-type": "application/json"
},
"processData": false,
"data": "{\"ServiceName\":\"ADM_Get_DynamicWebServiceResult\",\"objCommonParameters\":{\"_ProxyDetails\":{\"Password\":\"admin@123\",\"UserName\":\"summitadmin@dlpl.com\",\"ProxyID\":0,\"ReturnType\":\"JSON\",\"OrgID\":1},\"ServiceName\":\"Is_Category_TicketExists\",\"objDynamicWebService\":{\"InputString\":\"{\\\"CustomeAttributeID\\\":\\\"" + CustomAttributeID + "\\\",\\\"categoryId\\\":\\\"" + Selectedcategory + "\\\",\\\"userID\\\":\\\"" + Caller_ID + "\\\",\\\"instance\\\":\\\"" + SelectedInstance + "\\\",\\\"CustomeAttributeValue\\\":\\\"" + selectedcustAttribute + "\\\"}\"}}}"
}
var Isexiststicket = $.ajax(settings).done(function (response) {
if (response) {
result = response;
if (result.OutputObject != null && result.OutputObject.SUBROOT[0] != null) {
IncidentRaiseStatus = result.OutputObject.SUBROOT[0].IsTicket_Exists;
Counts = result.OutputObject.SUBROOT[0].Counts;
Tickets = result.OutputObject.SUBROOT[0].Tickets;
console.log(IncidentRaiseStatus, Counts, Tickets);
console.log('got the response');
}
if (IncidentRaiseStatus != undefined && IncidentRaiseStatus == "0") {
status = true;
console.log('status is true');
}
else if (IncidentRaiseStatus != undefined && IncidentRaiseStatus > 0) {
status = false;
}
else if (IncidentRaiseStatus == undefined) {
status = false;
console.log('IncidentRaiseStatus is undefined');
}
if (status == false) {
InitOnScreenNotification(validationMsg + '<br> : ' + Tickets, 'validationmsg');
console.log('status is false');
status = false;
}
}
}).fail(function (response, err) {
console.log("fail block");
console.log(response);
console.log(err);
status = false;
}).always(function () {
console.log("Completed");
})
}
else {
console.log('else block variables null');
InitOnScreenNotification('Please enter required data', 'validationmsg');
status = false;
}
}
catch (e) {
status = false;
console.log("catch block");
console.log(e.message);
console.log("error occured isTicketExists()");
}
return status;
}
Use Case #5: When a Change Request is created from a Service Request, the Description of the Change Request would be the Symptom of the Service Request. The Change Request Description should be cleared if it is created from a Service Request.
Page: Change > Change Record List > Select CR
JavaScript Logic: Clear the Change Request Description field (on page load) if it is created from a Service Request.
$(window).load(function(){
if (BodyContentPlaceHolder_lblChange_Request_Id.innerHTML == "")
{
(BodyContentPlaceHolder_txtDescription.value = "");
(BodyContentPlaceHolder_txtInformation.value = "");
}
});
Use Case #6: Based on the selected Vendor under the Vendor tab of the Incident details page, there should be an option to click on a link that opens the Vendor pop up displaying the Vendor details.
Page: Incident > Incident List > Select Incident > Vendor tab
JavaScript Logic: Create a link. On clicking the link, the Vendor pop-up should open (Vendor details page)
setInterval(function () { showLink(); }, 1000);
function showLink() {
var divID = $("#VendorLink");
if (divID.length == 0) {
$("#BodyContentPlaceHolder_ddlPartner").closest(".notranslate").append("<div id='VendorLink'> <a href='#'>Vendor Details</a> </div>");
$("#VendorLink").css("font-weight", "Bold");
}
if ($('#BodyContentPlaceHolder_ddlPartner').val().trim().length == 0)
{
$('#VendorLink').hide();
}
}
$(document).on('click', '#VendorLink', function () {
$('<div id="dialog" title="Vendor Details">').appendTo('#VendorLink');
$("#dialog").dialog({
autoOpen: false,
// position: 'center',
draggable: false,
width: 1300,
height: 500,
resizable: false,
modal: true,
});
$("#dialog").dialog('open')
$(".table").remove();
var element = $(
' <div class="container"> '
+ '<table class="table table-bordered" style="border: 1px solid black; width: 100%; word-wrap:break-word;table-layout: fixed;">'
+ ' <tbody >'
+ ' <tr>'
+ ' <td class="col-md-3"><strong> Vendor Name : </strong></td>'
+ ' <td class="col-md-3" id="VendorName"></label></td>'
+ ' <td class="col-md-3"><strong> Vendor ID : </strong></td> '
+ ' <td class="col-md-3" id="VendorID"></td>'
+ ' </tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Email ID : </strong></td>'
+ ' <td class="col-md-3" id="VendorEmailID"></td>'
+ ' <td class="col-md-3"><strong>Location : </strong></td>'
+ '<td class="col-md-3" id="VendorLocation"></td>'
+ '</tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Domain : </strong></td>'
+ ' <td class="col-md-3" id="VendorDomain"></td>'
+ ' <td class="col-md-3"><strong>Parent Vendor : </strong></td> '
+ ' <td class="col-md-3" id="ParentVendor"></td>'
+ ' </tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Contact Person :</strong></td>'
+ ' <td class="col-md-3" id="VendorContactPerson"></td>'
+ ' <td class="col-md-3"><strong>Designation :</strong></td> '
+ ' <td class="col-md-3" id="VendorDesignation"></td>'
+ ' </tr> '
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Contact Number :</strong></td>'
+ ' <td class="col-md-3" id="VendorContactNumber"></td>'
+ ' <td class="col-md-3"><strong>Mobile Number :</strong></td>'
+ ' <td class="col-md-3" id="VendorMobileNumber"></td>'
+ ' </tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Country :</strong></td>'
+ ' <td class="col-md-3" id="VendorCountry"></td>'
+ ' <td class="col-md-3"><strong>State :</strong></td> '
+ ' <td class="col-md-3" id="VendorState"></td>'
+ ' </tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>City :</strong></td> '
+ ' <td class="col-md-3" id="VendorCity"></td>'
+ ' <td class="col-md-3"><strong>Pin Code :</strong></td>'
+ ' <td class="col-md-3" id="VendorPinCode"></td>'
+ ' </tr>'
+ ' <tr>'
+ ' <td class="col-md-3"><strong>Address :</strong></td>'
+ ' <td class="col-md-3" id="VendorAddress"></td>'
+ ' <td class="col-md-3"><strong>Remarks :</strong></td> '
+ ' <td class="col-md-3" id="VendorRemarks"></td>'
+ ' </tr> '
+ ' <tr>'
+ ' <td><strong>Active :</strong></td>'
+ ' <td class="col-md-3" id="VendorActive"></td>'
+ ' <td class="col-md-3"><strong>Vendor :</strong></td>'
+ ' <td class="col-md-3" id="Vendor"></td>'
+ ' </tr>'
+ '</tbody>'
+ '</table>'
+ '</div>'
);
$('#dialog').append(element);
var _data = '{"ServiceName":"ADM_Get_DynamicWebServiceResult","objCommonParameters":{"_ProxyDetails": {"Password":"test@123","UserName":"manish.kk@symphonysummit.com","ProxyID":0,"ReturnType":"JSON","OrgID":1},"ServiceName":"SP_VendorDetails","objDynamicWebService":{"InputString":"{\\"CM_ID\\":\\" ' + $('#BodyContentPlaceHolder_ddlPartner').val() + '\\"}"}}}';
var _url = 'http://localhost/Summit_V5.8WS/REST/Summit_RESTWCF.svc/RESTService/CommonWS_JsonObjCall';
POST_Method(_url, _data);
function POST_Method(_url, _data) {
$.ajax({
type: "POST",
url: _url,
data: _data,
contentType: "application/json",
async: false,
dataType: "json",
success: function (Result) {
console.log(Result)
if (Result != undefined && Result != null && Result && Result.OutputObject != undefined && Result.OutputObject != null && Result.OutputObject.SUBROOT != undefined && Result.OutputObject.SUBROOT != null && Result.OutputObject && Result.OutputObject.SUBROOT) {
$('#VendorName').text(Result.OutputObject.SUBROOT[0].UserName);
$('#VendorID').text(Result.OutputObject.SUBROOT[0].EmpID);
$('#VendorEmailID').text(Result.OutputObject.SUBROOT[0].EmailID);
$('#VendorLocation').text(Result.OutputObject.SUBROOT[0].Location_Name);
$('#VendorDomain').text(Result.OutputObject.SUBROOT[0].Domain_Name);
$('#ParentVendor').text(Result.OutputObject.SUBROOT[0].ParentVendor);
$('#VendorContactPerson').text(Result.OutputObject.SUBROOT[0].ContactPerson);
$('#VendorDesignation').text(Result.OutputObject.SUBROOT[0].Designation);
$('#VendorContactNumber').text(Result.OutputObject.SUBROOT[0].ContactNo);
$('#VendorMobileNumber').text(Result.OutputObject.SUBROOT[0].MobileNo);
$('#VendorCountry').text(Result.OutputObject.SUBROOT[0].Country);
$('#VendorState').text(Result.OutputObject.SUBROOT[0].State);
$('#VendorCity').text(Result.OutputObject.SUBROOT[0].City);
$('#VendorPinCode').text(Result.OutputObject.SUBROOT[0].Pin);
$('#VendorAddress').text(Result.OutputObject.SUBROOT[0].Address);
$('#VendorRemarks').text(Result.OutputObject.SUBROOT[0].UserRemarks);
$('#Vendor').text(Result.OutputObject.SUBROOT[0].Vendor_Name);
$('#VendorActive').text(Result.OutputObject.SUBROOT[0].Active);
}
},
error: function (req, status, err) {
console.log('Something went wrong', status, err);
}
});
}
});
Use Case #7: While logging Incidents, the Asset selection is mandatory. However, if there is no Asset allocated to the user, the Asset selection should become non-mandatory.
Page: Incident > New Incident
JavaScript Logic: If there is no Asset allocated to a user, Asset selection should be non-mandatory while logging Incidents for the user.
function fnAssetvalidationJS() {
try {
var flagstatus = true;
if ($('#BodyContentPlaceHolder_divAssetAllocation').find('.nodata-normal')) {
$('.searchAssetContent .AssetCheckBox').each(function () {
if ($($('#BodyContentPlaceHolder_divAssetAllocation').find('tr')).length > 0) {
if (!$('.searchAssetContent .AssetCheckBox').is(':checked')) {
$('#BodyContentPlaceHolder_lblAssets').addClass('mandatoryField')
MarkRequiredInputs();
InitOnScreenNotification("Specify " + $('#BodyContentPlaceHolder_lblAssets').text().replace('*', ''), 'warning');
flagstatus = false;
}
}
});
}
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
return flagstatus;
}
Use Case #8: The End User should have the option to select Permanent/ Temporary/ Residential Address. If any of these options are selected, there should be an option to enter the address.
Page: Request > New Service Request
JavaScript Logic: There are 3 check boxes in a Service Catalog:
- Permanent Address
- Temporary Address
- Residential Address
If any of the above check boxes are selected, there should be corresponding text areas, Permanent Address, Temporary Address, Residential Address, that should become mandatory based on the selection of check box.
function fnAddressJS() {
try {
var
chkemergency = 'BodyContentPlaceHolder_chk_1999_570_True',
chkpermanent = 'BodyContentPlaceHolder_chk_2000_570_True',
chkresidential = 'BodyContentPlaceHolder_chk_2001_570_True',
gremergencytype = 'Group_571',
grpermanenttype = 'Group_572',
grresidentialtype = 'Group_573';
chkemergency = $('#' + chkemergency);
chkpermanent = $('#' + chkpermanent);
chkresidential = $('#' + chkresidential);
gremergencytype = $('#' + gremergencytype);
grpermanenttype = $('#' + grpermanenttype);
grresidentialtype = $('#' + grresidentialtype);
gremergencytype.hide();
grpermanenttype.hide();
grresidentialtype.hide();
if (chkemergency.is(':checked')) {
gremergencytype.show();
}
if (chkpermanent.is(':checked')) {
grpermanenttype.show();
}
if (chkresidential.is(':checked')) {
grresidentialtype.show();
}
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
return true;
}
Use Case #9: The user can update various fields in a Service Request, such as Username, Date of Birth, Address, Location, etc. However, if the user selects more than two fields, the Application should display a message stating that the user cannot modify more than 2 fields in a Service Request.
Page: Request > New Service Request
JavaScript Logic: There are 4 check boxes in a Service Catalog.
- Username
- Date of Birth
- Address
- Location
If more than 2 check boxes are selected, a message should display stating that more than 2 check boxes cannot be selected.
function fnfieldJS() {
var Note = " User cannot modify more than 2 fields in a Service Request";
if ($('#Group_313').find(':checkbox:checked').length > 0) {
var fields = $("#Group_313").find(':checkbox:checked').map(function () {
return this.value;
}).get();
if (fields.length > 2) {
InitOnScreenNotification(Note, 'information');
}
}
}
Use Case #10: In the E-mail ID field, the Application should allow to enter e-mail ids, only if the e-mail id contains "@symphonysummit.com". Otherwise, it should not allow the user to submit the request.
Page: Request > New Service Request
JavaScript Logic: Validate for "@symphonysummit.com" in the E-mail ID field. If the e-mail id is different, display a message stating that only symphonysummit e-mail ids are accepted.
function fnEmailJs() {
try {
var lblEmail = 'BodyContentPlaceHolder_lbl_379_132',
txtEmail = 'BodyContentPlaceHolder_txt_379_132_False';
lblEmail = $('#' + lblEmail);
txtEmail = $('#' + txtEmail);
str = $('#BodyContentPlaceHolder_txt_379_132_False').val();
str = str.split('@').slice(1);
var allowedDomains = ['symphonysummit.com'];
if ($.inArray(str[0], allowedDomains) == -1) {
{
InitOnScreenNotification("please enter valid " + lblEmail.text().replace('*', ''), 'warning');
return false;
}
}
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
return true;
}
Use Case #11: The Manager Search control should reflect for specific drop-down values.
Page: Request > New Service Request
JavaScript Logic:
- If Drop down Value = "Amend User", "New User", Enable Manager Search box
- If Drop down Value="Select", "Any Other Request", "Clarification", "Delete User", "Password Reset", "Report/Data Extraction", Disable Manager Search box
function fn() {
try {
var ddlEmployeetype = 'BodyContentPlaceHolder_ddl_465_150_False',
lblsearch = 'BodyContentPlaceHolder_lbl_464_150',
txtsearch = 'BodyContentPlaceHolder_uscUSER_464_150_False',
btnsearch = 'BodyContentPlaceHolder_btnUSER_464_150_False',
amenduserval = '337',
newuserval = '336';
ddlEmployeetype = $('#' + ddlEmployeetype);
lblsearch = $('#' + lblsearch);
txtsearch = $('#' + txtsearch);
btnsearch = $('#' + btnsearch);
if (ddlEmployeetype.val() == amenduserval || ddlEmployeetype.val() == newuserval) {
txtsearch.prop("disabled", false);
btnsearch.prop("disabled", false);
}
else {
txtsearch.prop("disabled", true);
btnsearch.prop("disabled", true);
txtsearch.val('');
$(".CallerInfoUsername").hide();
$(".user-details").hide();
$(".user-image").hide();
}
var string = document.URL;
var substring = 'SR_MyServiceRequestDetails.aspx';
if (string.indexOf(substring) !== -1) {
$('#BodyContentPlaceHolder_uscUSER_464_150_False').prop("disabled", true);
$('#BodyContentPlaceHolder_btnUSER_464_150_False').prop("disabled", true);
}
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
return true;
}
Use Case #12: Every Problem Record should have a Knowledge Record linked to it.
Page: Problem > Problem Record List > Problem Record
JavaScript Logic: When an Analyst tries to resolve a Problem Record, if a Knowledge Record is not linked to the Problem Record, display a pop up stating that a Knowledge Article should be selected for a Problem Record.
Use Case #13: While raising a Change Request from a Service Request only "Business Requirement" Change Type should be selected/auto- selected and grayed out. Analysts must not be able to select any other type of Change if it is requested from SR.
JavaScript Logic: While raising a CR from an SR only Change Type selected as Business Requirement should be selected/auto-selected and grayed out. Analysts should not be able to select any other type of Change Type if the CR is requested from an SR.
Use Case #14: The Actual PIR Date should be auto-populated based on the system time at the time of PIR submission.
Page: Change > Change Record
JavaScript Logic: At the time of PIR submission, populate the Actual PIR Date based on the system time.
$(document).ready(function () {
var systemDate = new Date($.now());
var month = systemDate.getMonth() + 1;
var date = systemDate.getDate();
var year = systemDate.getFullYear();
var PIRdate = year + '-' + (month < 10 ? '0' : '') + month + '-' + (date < 10 ? '0' : '') + date + " " + systemDate.getHours() + ":" + systemDate.getMinutes();
$('#BodyContentPlaceHolder_txtPlannedPIRDt').val(PIRdate);
$("#BodyContentPlaceHolder_txtPlannedPIRDt").unbind();
$("#BodyContentPlaceHolder_txtPlannedPIRDt").next('span').unbind();
$("#BodyContentPlaceHolder_txtPlannedPIRDt").attr('readOnly', 'true');
});
Use Case #15: While requesting for Software installation, the users should not select a date in past as the Software Installation Date.
Page: Request > New Service Request
JavaScript Logic: If the entered date < current date, display a pop up stating that the date should not be less than the current date.
function fnSoftwareinstallationDateJS() {
try {
var dtSoftwareinstallationDate = 'BodyContentPlaceHolder_dat_750_434_False',
dtSoftwareinstallationDate = $('#' + dtSoftwareinstallationDate);
var pickerOpts = { minDate: new Date(), showButtonPanel: true, dateFormat: "yy-mm-dd", buttonText: "", changeMonth: true, changeYear: true, yearRange: "-100:+50", beforeShow: beforeShowDatePicker }; //, onSelect: onSelectDatePicker
$(dtSoftwareinstallationDate).datepicker('destroy');
$(dtSoftwareinstallationDate).datepicker(pickerOpts);
}
catch (e) {
console.log('Rule Validation error:' + e.message);
}
}
Use Case #16: The RCA Deadline of auto-generated Problem Records (PRs) should be 4 days from the date of PR creation.
Page: Problem > Problem Record List > Problem Record
JavaScript Logic: Validate if it is an auto-generated Problem Record. If yes, the RCA Date should be Creation Date + 4 days
$(document).ready(function() {
try {
var d = new Date($.now());
var date = d.getDate(),
month = d.getMonth() + 1,
year = d.getFullYear(),
hours = d.getHours(),
minutes = d.getMinutes();
var SubmissionDate = year + '-' + (month < 10 ? '0' : '') + month + '-' + (date < 10 ? '0' : '') + date + " " + (hours < 10 ? '0' : '') + hours + ":" + (minutes < 10 ? '0' : '') + minutes;
var SDate = $('#BodyContentPlaceHolder_txtRCA_Submition_Date').val(SubmissionDate);
var TotalWorkingDays = 5, counter = 0;
while (TotalWorkingDays > 0) {
var today = new Date($.now(SDate));
today.setDate(today.getDate() + counter++);
switch (today.getDay()) {
case 0: case 6: break;// sunday & saturday
default:
TotalWorkingDays--;
};
}
var date = today.getDate(),
month = today.getMonth() + 1,
year = today.getFullYear(),
hours = today.getHours(),
minutes = today.getMinutes();
var RCADeadLine = year + '-' + (month < 10 ? '0' : '') + month + '-' + (date < 10 ? '0' : '') + date + " " + (hours < 10 ? '0' : '') + hours + ":" + (minutes < 10 ? '0' : '') + minutes;
if ($('#BodyContentPlaceHolder_txtRCA_Submition_Date').val().trim().length > 0) {
$('#BodyContentPlaceHolder_txtRCA_DeadLine').datepicker("option", "disabled",true);
$('#BodyContentPlaceHolder_txtRCA_DeadLine').val(RCADeadLine);
//$("#BodyContentPlaceHolder_txtRCA_DeadLine").unbind();
//$("#BodyContentPlaceHolder_txtRCA_DeadLine").next('span').unbind();
$('#BodyContentPlaceHolder_txtRCA_DeadLine').attr('readOnly', 'true');
}
}
catch (e) {
console.log('Rule Validation Error : ' + e.message);
}
return true;
});
Use Case #17: Restrict few special characters in Private Log, Information, Solution, User Communication, and Description.
Page: Incident > Incident List > Select Incident
JavaScript Logic: Validate if there is special characters in Private Log, Information, Solution, User Communication, and Description. If yes, display a pop up stating that special characters are not allowed.
$(function () {
$("#BodyContentPlaceHolder_txtInformation").keypress(function (e) {
var keyCode = e.keyCode || e.which;
//Regex for Valid Characters i.e. Alphabets and Numbers.
var regex = /^[A-Za-z0-9]+$/;
//Validate TextBox value against the Regex.
var isValid = regex.test(String.fromCharCode(keyCode));
if (!isValid) {
return false;
}
return isValid;
});
});
Use Case #18: There is a Custom Field called 'Lab ID' on the LOG NEW INCIDENT page. This field should be hidden if Category is "Inquiry". However, it should be mandatory for any other Category.
Page: Incident > New Incident
JavaScript Logic: If Category = Inquiry, the Lab ID should be hidden. However, Category is other than Inquiry, the Lab ID should be mandatory.
function LogNewTicketCustomOnSaveJS() {
var InstanceCtrl = $('#BodyContentPlaceHolder_UCInstanceList_lstInstance');
if (InstanceCtrl.val() == 'DLPL') {
if(!LabIDMandatry())
return false;
}
return true;
}
var CategoryList = ['12','2050', '2051', '2054', '2055', '2056', '2057', '2067', '2068', '2069', '2071', '2086', '2263'];
var categoryHdnID = $("#BodyContentPlaceHolder_hdnCategoryID");
$(document).on("hidden.bs.modal", ".bootbox.modal", function (e) {
alert($("#BodyContentPlaceHolder_txtOpenCategory").val());
alert(CategoryList.indexOf(categoryHdnID.val()));
var lblid = $("#BodyContentPlaceHolder_lblCF_155");
if ($("#BodyContentPlaceHolder_txtOpenCategory").val()!='' && categoryHdnID.val()>0 && CategoryList.indexOf(categoryHdnID.val()) == -1) {
lblid.addClass('mandatoryField');
lblid.attr('style', 'color:#6f94b6');
MarkRequiredInputs();
}
else {
lblid.attr('style', 'color:#6f94b6');
lblid.removeClass('mandatoryMark').removeClass('mandatoryField').children('.mandatory').remove();
}
});
function LabIDMandatry() {
var lblid = $("#BodyContentPlaceHolder_lblCF_155");
var txtLabID = $("#BodyContentPlaceHolder_lblCF_155");
if (lblid != null && lblid !== 'undefined' && lblid != null && lblid !== 'undefined') {
if (lblid.hasClass('mandatoryField')) {
if (txtLabID.val().trim().length == 0) {
InitOnScreenNotification("Specify " + lblid.text().replace('*', ''), 'validationmsg');
return false;
}
}
}
return true;
}
Use Case #19: The End User has an option to select the Date of Birth in the Service Request form. Validate if the user is above 18 years from the Date of Birth and do not allow the user to select future date.
Page: Request > New Service Request
JavaScript Logic: If the Date of Birth > Current Date, do not allow to submit and display a pop up indicating the date of birth cannot be a future date.
If |Current Date - Date of Birth| < 18 years, display a pop up indicating the Service Request cannot be submitted.
function fnDobJS() {
try {
//all the control id with respective variables
var dtDateofBirth = 'BodyContentPlaceHolder_dat_750_434_False';
dtDateofBirth = $('#' + dtDateofBirth);
// age should be above 18 years
dtDateofBirth.datepicker('destroy');
var pickerOpts = { maxDate: "new Date()-18years", showButtonPanel: true, dateFormat: "yy-mm-dd", buttonText: "", changeMonth: true, changeYear: true, yearRange: "-100:+50", beforeShow: beforeShowDatePicker };
dtDateofBirth.datepicker(pickerOpts);
}
catch (e) {
console.log('Rule Validation error:' + e.message); //log error message
}
return true;
}
Use Case #20: When the End User rejects an Asset, an Incident should be created.
Page: Asset > My Assets
JavaScript Logic:
- When the End User clicks the Reject button, call an API to create the Incident.
- The Incident Symptom should be "Asset rejected by *Username*".
- The Incident Description should comprise of asset details like "Serial Number", "Host Name".
$("#BodyContentPlaceHolder_btnRejectAsset").on("click", function ()
{
var SelectedAssetID=0;
$('#BodyContentPlaceHolder_gvMyAssetList tr').each(function () {
if (!this.rowIndex) return;
var chkAccept = $(this).find('input[id*="btngvAccept"]');
if (chkAccept != null && chkAccept != 'undefined' && chkAccept.attr('checked') === 'checked')
{
SelectedAssetID = $(this).find("td:eq(2)").first().text();
console.log('Selected ID:'+SelectedAssetID);
window.localStorage.setItem('AM_MyAssetlist.aspx', SelectedAssetID);
return;
}
});
});
$(document).ready(function(){
var SelectedAssetID = window.localStorage.getItem('AM_MyAssetlist.aspx');
console.log('Selected ID:'+SelectedAssetID);
if(SelectedAssetID != null && SelectedAssetID != 'undefined' && SelectedAssetID > 0)
{
console.log('Selected ID1:'+SelectedAssetID);
var JsonWsparams ="{\"url\":\"#url#\",\"params\":\"{\\\"RequestType\\\":\\\"RemoteCall\\\",\\\"incidentParamsJSON\\\":{\\\"IncidentContainerJson\\\":\\\"{\\\\\\\"TicketInformation\\\\\\\":{\\\\\\\"Information\\\\\\\":\\\\\\\"Desc: AssetID:" + SelectedAssetID +" has been Rejected\\\\\\\"},\\\\\\\"Ticket\\\\\\\":{\\\\\\\"LoggedBy\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"Assigned_WorkGroup_Name\\\\\\\":\\\\\\\"IT Infrastructure\\\\\\\",\\\\\\\"Assigned_Engineer_Email\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Caller_EmailID\\\\\\\":\\\\\\\"Prasant@symphonysummit.com\\\\\\\",\\\\\\\"Medium\\\\\\\":\\\\\\\"Application\\\\\\\",\\\\\\\"SLA_Name\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Impact_Name\\\\\\\":\\\\\\\"Low\\\\\\\",\\\\\\\"Urgency_Name\\\\\\\":\\\\\\\"Medium\\\\\\\",\\\\\\\"Priority_Name\\\\\\\":\\\\\\\"p1\\\\\\\",\\\\\\\"Status\\\\\\\":\\\\\\\"New\\\\\\\",\\\\\\\"PageName\\\\\\\":\\\\\\\"LogTicket\\\\\\\",\\\\\\\"Category_Name\\\\\\\":\\\\\\\"Server\\\\\\\",\\\\\\\"OpenCategory_Name\\\\\\\":\\\\\\\"CCat1\\\\\\\",\\\\\\\"SLA\\\\\\\":\\\\\\\"0\\\\\\\",\\\\\\\"Org_Id\\\\\\\":\\\\\\\"\\\\\\\",\\\\\\\"Sup_Function\\\\\\\":\\\\\\\"Info\\\\\\\",\\\\\\\"Source\\\\\\\":\\\\\\\"Mobile App\\\\\\\",\\\\\\\"Description\\\\\\\":\\\\\\\"Symptom:AssetID:" + SelectedAssetID + " has been Rejected\\\\\\\",\\\\\\\"Classification_Name\\\\\\\":\\\\\\\"Server\\\\\\\"},\\\\\\\"Updater\\\\\\\":\\\\\\\"Caller\\\\\\\",\\\\\\\"SelectedAssets\\\\\\\":\\\\\\\""+ SelectedAssetID +"\\\\\\\",\\\\\\\"CustomFields\\\\\\\":[]}\\\"},\\\"_ProxyDetails\\\":{\\\"OrgID\\\":\\\"0\\\",\\\"UserName\\\":\\\"#uname#\\\",\\\"Password\\\":\\\"#pwd#\\\",\\\"ProxyID\\\":0,\\\"ReturnType\\\":\\\"JSON\\\",\\\"TokenID\\\":\\\"\\\"}}\"}";
console.log("{\"param\":"+escape(JsonWsparams)+"}");
$.ajax({
url: "#wsinvoke#",
method: "POST",
data:"{\"param\":\""+escape(JsonWsparams)+"\"}",
contentType: "application/json",
success: function (data){
/**Custom code…**/
//console.log(data);
window.localStorage.removeItem('AM_MyAssetlist.aspx');
InitOnScreenNotification("Incident logged successfully.", "warning",3000);
},
error: function (jqXHR, a) {
/**Custom code…**/
window.localStorage.removeItem('AM_MyAssetlist.aspx');
}
});
}
});
Confluence Cloud Migration Alert: Please refer to known issues you may encounter in Confluence Cloud: https://eitdocs.atlassian.net/wiki/x/wDGwAQ