- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:00 PM
Hi,
Please find below scenario:
On Incident form,
if state field old value is New|1 and I change it to inProgress|2, then it should popup an alert as old value : New|1 and new value: inProgess|2.
Now, if I change state field New|1 again then it should be alerted like oldValue: inProgress|2 and newValue : New|1
Note: Form should not be saved. It should be achieved by without saving form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:05 PM
For above use case please find below solution :
We need to write on load client script on incident table :
function onLoad() {
//Type appropriate comment here, and begin script below
var oldStateValue = g_form.getValue('state');
function showAlert() {
var newStateValue = g_form.getValue('state');
alert('Old State: ' + oldStateValue + '\nNew State: ' + newStateValue);
oldStateValue = newStateValue;
}
g_form.getControl('state').addEventListener('change', showAlert);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:20 PM
Hi @NishantDhole ,
For above use case please find below solution :
We need to write on load client script on incident table :
function onLoad() {
//Type appropriate comment here, and begin script below
var oldStateValue = g_form.getValue('state');
function showAlert() {
var newStateValue = g_form.getValue('state');
alert('Old State: ' + oldStateValue + '\nNew State: ' + newStateValue);
oldStateValue = newStateValue;
}
g_form.getControl('state').addEventListener('change', showAlert);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2024 11:04 PM
@NishantDhole if that is the case then yeah you can go with the below code:
function onLoad() {
// Capture the initial value of the state field
var oldStateValue = g_form.getValue('state');
// Define the function to display the alert with old and new state values
function showAlert() {
var newStateValue = g_form.getValue('state');
alert('Old State: ' + oldStateValue + '\nNew State: ' + newStateValue);
oldStateValue = newStateValue; // Update the old state value to the current state
}
// Add an event listener to the state field to detect changes
g_form.getControl('state').addEventListener('change', showAlert);
}
…………………………………………........................................................................................
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.
…………………………………………........................................................................................
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:05 PM
For above use case please find below solution :
We need to write on load client script on incident table :
function onLoad() {
//Type appropriate comment here, and begin script below
var oldStateValue = g_form.getValue('state');
function showAlert() {
var newStateValue = g_form.getValue('state');
alert('Old State: ' + oldStateValue + '\nNew State: ' + newStateValue);
oldStateValue = newStateValue;
}
g_form.getControl('state').addEventListener('change', showAlert);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:20 PM
Hi @NishantDhole ,
For above use case please find below solution :
We need to write on load client script on incident table :
function onLoad() {
//Type appropriate comment here, and begin script below
var oldStateValue = g_form.getValue('state');
function showAlert() {
var newStateValue = g_form.getValue('state');
alert('Old State: ' + oldStateValue + '\nNew State: ' + newStateValue);
oldStateValue = newStateValue;
}
g_form.getControl('state').addEventListener('change', showAlert);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 11:26 PM
Hi @Hiteish22,
you can achieve this requirement using onChange Client Script.
Please mark my response as correct and helpful if it helped solved your question.
Thanks,
Rohit Suryawanshi