- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-21-2022 09:17 PM
Hi Team.
I have to hide particular related list when my affected user is "abel tuter"
for that I have tried with UI policy and on-load client script even I have used on-change client script and converted into on-load client script.
That all working fine for on-change when i change the value of affected user but that all is not working for on-load when I load the form.
In PDI I am getting same issue.
My code is like below
On load client script-
UI Policy-
The name of related list I am getting from list control
Please help me here...?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-22-2022 12:27 AM
function onLoad() {
ScriptLoader.getScripts(['sn_si.SecurityIncidentConstants.jsdbx'], function() {
var siConst = sn_si.SecurityIncidentConstants;
g_form.hideRelatedLists();
var group = "AFFECTED_ITEMS"; // the default
var previousIncidentId = g_user.getClientData("incident"); // previous incident user were on
var currentIncidentId = g_form.getUniqueValue(); // currently loaded incident
if (previousIncidentId === currentIncidentId) {
group = g_user.getClientData("group");
} else {
siConst.setLastRelatedList(group, currentIncidentId); // set state for the new incident
}
var lists = siConst.getList(group);
if (typeof group === "undefined" || group === "") {
g_form.showRelatedLists();
} else {
for (var i = 0; i < lists.length; i++)
g_form.showRelatedList(lists[i]);
}
// your code
var ab = g_form.getValue("affected_user");
if (ab == "62826bf03710200044e0bfc8bcbe5df1") {
g_form.showRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
} else {
g_form.hideRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
}
});
}
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-21-2022 11:41 PM
please share both the scripts so that I can help
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-21-2022 11:58 PM
OOB script on load client script-
function onLoad() {
ScriptLoader.getScripts(['sn_si.SecurityIncidentConstants.jsdbx'], function() {
var siConst = sn_si.SecurityIncidentConstants;
g_form.hideRelatedLists();
var group = "AFFECTED_ITEMS"; // the default
var previousIncidentId = g_user.getClientData("incident"); // previous incident user were on
var currentIncidentId = g_form.getUniqueValue(); // currently loaded incident
if (previousIncidentId === currentIncidentId) {
group = g_user.getClientData("group");
} else {
siConst.setLastRelatedList(group, currentIncidentId); // set state for the new incident
}
var lists = siConst.getList(group);
if (typeof group === "undefined" || group === "") {
g_form.showRelatedLists();
} else {
for (var i = 0; i < lists.length; i++)
g_form.showRelatedList(lists[i]);
}
});
}
My script-
function onLoad() {
//Type appropriate comment here, and begin script below
var ab = g_form.getValue("affected_user");
if (ab == "62826bf03710200044e0bfc8bcbe5df1") {
g_form.showRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
alert("a");
} else {
g_form.hideRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
alert("b");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-22-2022 12:27 AM
function onLoad() {
ScriptLoader.getScripts(['sn_si.SecurityIncidentConstants.jsdbx'], function() {
var siConst = sn_si.SecurityIncidentConstants;
g_form.hideRelatedLists();
var group = "AFFECTED_ITEMS"; // the default
var previousIncidentId = g_user.getClientData("incident"); // previous incident user were on
var currentIncidentId = g_form.getUniqueValue(); // currently loaded incident
if (previousIncidentId === currentIncidentId) {
group = g_user.getClientData("group");
} else {
siConst.setLastRelatedList(group, currentIncidentId); // set state for the new incident
}
var lists = siConst.getList(group);
if (typeof group === "undefined" || group === "") {
g_form.showRelatedLists();
} else {
for (var i = 0; i < lists.length; i++)
g_form.showRelatedList(lists[i]);
}
// your code
var ab = g_form.getValue("affected_user");
if (ab == "62826bf03710200044e0bfc8bcbe5df1") {
g_form.showRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
} else {
g_form.hideRelatedList("REL:c3979d351b310110d8de6464604bcbe0");
}
});
}
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-22-2022 12:53 AM
Now It is working.
Thank u so much Ankur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-22-2022 12:57 AM
Glad to know.
Please mark my response as correct and helpful to close the thread.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader