Display info message on list once record is created in the table
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I am using below Sever script in Related LIST UI Action. whenever click on UI Action record will created if does not exists and if it exists it wont create any anything. My Requirement whenever is created it should show a message in list view Below is my existiing code
// Client-side callback to refresh the related list after server-side execution
function refreshRelatedList() {
g_form.refreshRelatedList('sn_customerservice_contact_relationship'); // Forces a refresh of the related list
}
// Server-side logic (your original code)
(function() {
var contact = current.sys_id;
var account = current.account;
var oldResp = '8c47fe14833d42d46c06c3efeeaad329'; // PM – auto notify
var newResp = '3d6bd2cf2be03614e5f9f646c891bf1c'; // Automated PM Notification
// Try to find the "auto notify" record
var grOld = new GlideRecord('sn_customerservice_contact_relationship');
grOld.addQuery('contact', contact);
grOld.addQuery('company', account);
grOld.addQuery('responsibility', oldResp);
grOld.query();
if (grOld.next()) {
// If PM – auto notify exists, update it to Automated PM Notification
grOld.responsibility = newResp;
if (grOld.update()) {
gs.addInfoMessage(
'Updated PM – auto notify to Automated PM Notification for ' +
contact.getDisplayValue()
);
} else {
gs.addErrorMessage(
'Failed to update to Automated PM Notification for ' +
contact.getDisplayValue()
);
}
} else {
// If no "auto notify" exists at all, create only Automated PM Notification
var grNew = new GlideRecord('sn_customerservice_contact_relationship');
grNew.initialize();
grNew.contact = contact;
grNew.company = account;
grNew.responsibility = newResp;
if (grNew.insert()) {
gs.addInfoMessage(
'Created Automated PM Notification for ' +
contact.getDisplayValue()
);
gs.addInfoMessage('Automated PM has been created');
} else {
gs.addErrorMessage(
'Failed to create Automated PM Notification for ' +
contact.getDisplayValue()
);
}
}
gs.info('UI Action completed for record ' + current.sys_id);
})();
// Call the client-side refresh after server-side execution
refreshRelatedList();
0 REPLIES 0
