- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 07:46 AM
I've got a UI Action under the 'Related Links' called 'Generate/Continue BIA'. What I'm wanting to do is apply some logic so that it checks if the entries in the 'Divisional Application Owner' or 'Technical Application Owner' are active. If either one of the users are inactive and a user clicks on the 'Generate/Continue BIA' link, it should generate an error message 'The BIA cannot be generated/continued until both role holders are active' and keep them on the same page.
I was just wondering how I would get this applied to the UI action?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:57 AM
Hi,
update as this
function invokeAssessment() {
if(g_form.getReference('u_business_owner').active.toString() == 'true' && g_form.getReference('u_custodian').active.toString() == 'true'){
checkCurrentBia();
}
else{
g_form.addErrorMessage('The BIA cannot be generated/continued until both role holders are active');
}
}
function checkCurrentBia(){
var businessApp = g_form.getUniqueValue();
//Access the glide ajax script include with the current sys id as a parameter
var gaAssessment = new GlideAjax('LBGBiaUtils');
gaAssessment.addParam('sysparm_name', 'currentAssessmentAjax');
gaAssessment.addParam('sysparm_bus_app',businessApp);
gaAssessment.getXML(generateAssessment);
function generateAssessment(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
var data = answer.evalJSON(true);
if (data.wipBia == 'false') {
//generate pop up of UI page lbg_bia_dialog
var displayValue = g_form.getDisplayValue();
var biaDecisionPage = "lbg_bia_dialog";
var dialogWindow = new GlideModal(biaDecisionPage, false, "modal-md");
dialogWindow.setTitle(getMessage("Type of BIA"));
dialogWindow.setPreference("displayValue", displayValue);
//sysparm_id is the sys id of the current business app
dialogWindow.setPreference("sysparm_id", g_form.getUniqueValue());
dialogWindow.render();
window.g_parentDialog = dialogWindow;
} else {
gsftSubmit(null, g_form.getFormElement(), 'action_bia');
}
}
}
if (typeof window == 'undefined')
openCurrentBia();
function openCurrentBia() {
var util = new LBGBiaUtils();
var data = util.currentAssessment(current.getValue('sys_id'));
var urlArray = [];
urlArray.push(data.environmentUrl);
urlArray.push(data.biaInstance);
urlArray.push(data.biaMetricType);
var instanceUrl = gs.getMessage('lbg.assessment.redirect.url' , urlArray);
action.setRedirectURL(instanceUrl);
}
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
‎07-26-2022 07:55 AM
Hello
You can write in ui action script like below hoping both the fields are referring to user table
But make sure your client script is not "Client" checked.i.e client check box should be unchecked
if(current.divisional_application_owner_filed_name.active!=true || current.technical_application_owner_field_name.active!=true)
{
gs.addErrorMessage('The BIA cannot be generated/continued until both role holders are active');
current.setAbortAction(true);
}
please mark my answer correct if it helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 08:05 AM
Hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 08:07 AM
yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2022 07:55 AM
Hi,
It means both users should be active to show the UI action on form
update UI action condition as this
current.u_divisional_application_owner.toString() == 'true' && current.u_technical_application_owner.toString() == 'true'
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader