Hello friends,
In the Service-Now application, if multiple Fulfiller users are examining an incident form at the same time and one of them saves what’s on their screen, problems will occur when the other users, unaware of this, save the form.
To prevent this, all you need to do is add the following code under System Definition-> Client Scripts.
- Select the menu.
- Select the table you want to work on (since we’ll be working on incident, we selected Incident)
- The field where the code will be written
Code:
// For support of warning when two people are editing the same record.
function onSubmit() {
var updatedOn = gel('onLoad_sys_updated_on');
if (!updatedOn)
return;
updatedOn = updatedOn.value;
if (!updatedOn)
return;
var sysid_gel = gel('sys_uniqueValue');
var sysid = sysid_gel.value;
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',sysid);
gr.query();
if (gr.next()) {
var dbUpdatedOn = gr.sys_updated_on + '';
var dbUpdatedBy = gr.sys_updated_by + '';
} else
return;
if (updatedOn != dbUpdatedOn) {
return confirm("Bu çağrı üzerinde az önce " + dbUpdatedBy+ " işlem yapmıştır. Kaydetmek istediğinize emin misiniz? "
+ "Record has been updated by " + dbUpdatedBy + " since you opened it - "
+ "overwrite those changes with yours? Note that Additional comments and Work notes are "
+ "additive and will not be overwritten.");
}
}
function getGroupSys_id_Ajax2(main_cat, sub_cat_1, sub_cat_2, sub_cat_3)
{
var ga = new GlideAjax('getGroupSys_id2');
ga.addParam('sysparm_name','getGroupSys_id2');
ga.addParam('sysparm_main_cat', main_cat);
ga.addParam('sysparm_sub_cat_1', sub_cat_1);
ga.addParam('sysparm_sub_cat_2', sub_cat_2);
ga.addParam('sysparm_sub_cat_3', sub_cat_3);
//ga.getWaitXML();
//ga.getAnswer();
ga.getXML(function (response) {
var data = response.responseXML.documentElement.getAttribute("answer").split('|');
console.log(data.length);
if(data.length > 1)
{
g_form.setValue("assignment_group", data[0]);
//alert(g_form.getValue('assignment_group') != 'd8e6445e37c94600828c148543990e7b');
if((g_form.isNewRecord()) || (!g_form.isNewRecord() && g_form.getValue('u_main_category') == '' && g_form.getValue('state') == '1') )
{
g_form.setValue("impact", data[2]); //impact
g_form.setValue("urgency", data[3]); //urgency
g_form.setValue("priority", data[1]); //priority
}
/*else
{
g_form.setVisible('impact', false);
g_form.setVisible('urgency', false);
}*/
}
console.log(data);
});
//var result = ga.getXML(getGroupSys_idParse);
//console.log("******* " + result);
//return result;
}
function getGroupSys_idParse(response) {
return response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
}
function getGroup(grp_sys_id)
{
var result = "";
var get = new GlideRecord("sys_user_group");
get.addQuery("sys_id", grp_sys_id);
get.query();
while(get.next())
{
result = get.name;
}
return result;
//alert(grp_sys_id);
}


Share your experience
Got a question, a different solution or a note to add?
Log in or join us to write a comment.
Log in ↗︎Sign up ↗︎