- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2023 09:33 PM
Hi, what are the results of your debugging\testing? what exactly is\is not working?
Evaluating screenshots is not ideal, perhaps you could share your code as plain text.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 01:03 AM
Thanks Tony!!
what are the results of your debugging\testing? -- In the alert we are getting old value of category
what exactly is\is not working? - if we change category to software in the list and sub category changes to email then record should not submit to server. Script should check is it category is software or not, if yes, then the record should abort.
On cell edit Client script:
Field name: Sub category
Script:
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('incidenttTable');
ga.addParam('sysparm_name', 'tablequery');
ga.addParam('sysparm_syssid', sysIDs);
ga.addParam('sysparm_newvalues', newValue);
ga.getXML(myid);
function myid(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert('ramya' + answer);
if (answer == 't1')
if (newValue == 'email')
alert('anns' + answer);
saveAndClose = false;
}
callback(saveAndClose);
}
Script Include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 05:09 AM
Hi @Community Alums ,
You can acheive this without coding.
1. Create Before Insert/Update BR.(It'll work for list editing too)
2. Filter conditions : category is software
Subcategory is Email
3. Under actions Tab: select Add message & Abort action.
Note: Script includes + OncellEdit scripts are not efficeint together , You can user before BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 06:32 AM
Hi Khasim,
Thanks!!
My lead want me to do with On cell Edit.
Any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:53 PM
Hi @Community Alums ,
Here are the modified Scripts.
-----Script Include-----
var GetCatagory = Class.create();
GetCatagory.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCat: function() {
var sysId = this.getParameter('sysparm_sysId');
// var subCat = this.getParameter('sysparm_subCat');
gs.info('sys_id' + sysId);
var gr = new GlideRecord('incident');
gr.get(sysId);
gr.query();
if (gr.next()) {
if (gr.category == 'software') {
return true;
} else {
return false;
}
}
},
type: 'GetCatagory'
});
----------Client Script----------
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose;
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('GetCatagory');
ga.addParam('sysparm_name', 'getCat');
ga.addParam('sysparm_sysId', sysIDs);
ga.getXML(myid);
function myid(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer && newValue == 'email') {
saveAndClose = false;
alert("Hi! Email can't be selected for category of 'software' try other combination");
callback(saveAndClose);
} else {
saveAndClose = true;
callback(saveAndClose);
}
}
}