Client Script spModal.open() button is not working for service catalog condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 02:10 AM - edited 08-12-2024 11:12 PM
Hi Experts,
I'm trying to add a disclaimer condition on catalog Item, whenever user tries to request it he has to accept a disclaimer else, it should clear out the field on form. i can't do it any other way , as the catalog item is not to be modified.
I'm trying to use the spModal.open() method , with which i've very limited experience, i'm was hoping to use the output of "Accept" or "reject" button to to show form message and clear form field.
here My code always is going in if block and never in else block where it is supposed to clear the fields.
Kindly guide with your expertise. below is code.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var groupValue = newValue;
if (groupValue == 'group_sys_id') {
spModal.open({
title: 'Confirm Action',
message: '<strong>IMPORTANT</strong>: <p style="color:red">important Disclaimer</p>' ,
buttons: [{
label: 'Accept',
primary: true,
},
{
label: 'Decline',
cancel: true,
}
]
}).then(function(confirmed) {
if (confirmed) {
alert('test1'). // Code always go in this block no matter if i choose Accept or decline
g_form.addInfoMessage("You Accepted the disclaimer ")
} else {. // Ideally if user select decline the field value should be cleared
alert('test')
g_form.clearValue('select_groups');
g_form.addInfoMessage('You declined the disclaimer .');
}
});
}
}
Regards,
Varun Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 02:20 AM - edited 08-09-2024 02:22 AM
You could use confirm() method on OnSubmit() catalog client script.
var conf = confirm("Your_message_disclaimer") ;
if (conf == true) {
return true ;
} else {
g_form.clearValue('select_groups') ;
g_form.addInfoMessage("You declined the disclaimer") ;
return false ;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 04:29 AM
Hi Alp,
thanks for quick response, is it not possible to update above mentioned onChange script to full fill the requirement i'm implementing?
Regards,
Varun Sharma