Need help with OnLoad modal in portal

john_duchock
Kilo Guru

I am trying to create a portal pop-up window (modal) that displays when a user accesses a CLOSED task record in portal (incident, request item, change, etc.).  This modal should instruct the user that the record they are accessing is closed and provide them with instructions on what to do next.

I am unable to craft the proper onLoad client script to trigger the modal.  I am wondering if anyone else has something similar they could share...

Thanks

 

1 ACCEPTED SOLUTION

Here you go.  This is tested an working on an INC record.

Server Script:

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */

var id = '';
if(input.action === 'checkRec'){
id = $sp.getParameter('sys_id');
}

data.active_record = isRecordActive(id);

function isRecordActive(sysID){
var active = '';
var task = new GlideRecord('task');
task.get(sysID);
active = task.active;
return active.toString();
}

})();

 

Client Script:

function(spModal) {
/* widget controller */
var c = this;

var activeRecord = '';

c.server.get({
action: 'checkRec'
}).then(function(response){
activeRecord = response.data.active_record;

if(activeRecord == 'false'){
spModal.open({
title: 'This is a test title for false record',
message: 'This is a test message.',
buttons: [{label:'OK', primary:true}]
});
}
});

}

 

View solution in original post

11 REPLIES 11

john_duchock
Kilo Guru

oh yeah...bang on...

works for all types of tasks, so it's extendable to RITM records !

Thanks tons for the help !!

 

No problem!