- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:41 AM
Hello!
Im working on a functionality that will allow to change the status of a record when a button is clicked.
I have an UI Action (client) so that when the button is clicked 'reason for reject' shows up and is set to mandatory:
I want the approver to be obliged to provide 'reject reason' to be able to change the status to 'rejected'.
Here is my UI action:
is it possible to call Script Include that will handle the logic of the record update? (changing the field value to 'rejected' and adding the 'reject reason').
Thank you in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:14 AM
I corrected this in my reply above, see this
if( g_form.getValue('u_activity')== ''){ // this if was wrong
return false; //Abort submission
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:01 AM
Action name uniquely identifies a ui action, this is to essentially works as server side form save button when that line executes, and we pass the action name to register what triggered the same(mimicking a server side button press).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:05 AM
function runClientCode(){
//alert("test");
var activityField = g_form.getControl('u_activity');
// Make the field visible
g_form.setDisplay('u_activity', true);
// Make the field mandatory
g_form.setMandatory('u_activity', true);
if( == false){
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'expense_reject_action'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if(typeof window == 'undefined')
runBusRuleCode();
//Server-side function
function runBusRuleCode(){
current.u_reject_reason = 'Rejected';
current.exp_amount = 0;
current.update();
action.setRedirectURL(current);
gs.addInfoMessage('Record rejected successfully.');
current.update();
gs.addInfoMessage('You did it!');
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:07 AM
correction;
// Client-Side Script
function runClientCode() {
// Example of setting up a condition for the if statement
if (!g_form.getValue('u_activity')) {
return false; // Abort submission if u_activity is empty
}
var activityField = g_form.getControl('u_activity');
g_form.setDisplay('u_activity', true); // Make the field visible
g_form.setMandatory('u_activity', true); // Make the field mandatory
// Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'expense_reject_action');
}
// Code that runs without 'onclick'
if (typeof window === 'undefined') {
runBusRuleCode();
}
// Server-Side Script
function runBusRuleCode() {
current.u_reject_reason = 'Rejected';
current.exp_amount = 0;
current.update(); // Update the record with new values
gs.addInfoMessage('Record rejected and updated successfully.');
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:09 AM
So what is happening now?
What are you using the below line for
var activityField = g_form.getControl('u_activity');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:10 AM
I removed it. it is the remaining part of the previous script version