UI Action is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I have a requirement where :
when only on assess and RCA state reject button should be visible ( working)
and when if clicked on assess then first make the work notes mandatory (its working) it should move back to new state (not working) & if clicked on RCA first it should make the work notes mandatory and then it should move back to assess state. (not working).
here is the code:
onclick: setnotes()
condition :(current.state == 102 || current.state == 103) &&( current.approval == 'not requested');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
The issue here is that you're mixing client-side code (UI actions) with server-side operations (changing current.state and calling current.update()) in the same function.
When you call saveNew() or saveAssess() from the client-side function, those server-side lines never execute, because the client script cannot directly modify current or call update().
current.state = 101; current.update(); is server-side only.Your onclick function runs in the browser, so those lines are ignored.gsftSubmit() submits the form with the action name (reject_problem), but you haven't implemented the logic for state change in the server-side UI Action or Business Rule.
You need to split responsibilities:
-
Client-side UI Action:
- Validate work notes.
- Make
work_notesmandatory. - Submit the form with a custom action name.
function setnotes() {
var prbvalue = g_form.getValue('state');
var workvalue = g_form.getValue('work_notes');
if (workvalue == '') {
g_form.setMandatory('work_notes', true);
alert('Please fill in Work Notes before rejecting.');
return false; // Stop submission
}
if (prbvalue == '102') {
gsftSubmit(null, g_form.getFormElement(), 'reject_to_new');
} else if (prbvalue == '103') {
gsftSubmit(null, g_form.getFormElement(), 'reject_to_assess');
}
}
2. Server-side UI Action (with Server checked):
- Create two separate actions:
reject_to_newandreject_to_assess. - In each, update the state and redirect.
Example for reject_to_new:
current.state = 101; // New
current.update();
action.setRedirectURL(current);
Example for reject_to_assess:
current.state = 102; // Assess
current.update();
action.setRedirectURL(current);
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
that means -
create a new (1st)Ui action with action name - reject_to_new - client ( checkbox false) -with below code
and show update/insert checked also also form button and rest unchecked-->
current.state = 101; // New current.update(); action.setRedirectURL(current);
create 2nd Ui action with action name - reject_to_assess - client ( check box false) with below code ->
&& show update/insert checked also form button and rest unchecked -->
current.state = 102; // Assess current.update(); action.setRedirectURL(current);
keep the rest of the logic in main Ui action - which is visible on the form (Reject) where the client check box is true. as given below -
is my understanding correct??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
25m ago
i have tried you method its working partially but i am facing with one error have you got any idea :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
54m ago
Hi @tushar_ghadage ,
Can you change your UI Action to server callable only, no client callable and try to add below script
Condition - (current.state == 102 || current.state == 103) && current.approval == 'not requested'
if (current.work_notes.nil()) {
gs.addErrorMessage("Work notes are mandatory to reject.");
action.setRedirectURL(current);
return;
}
if (current.state == 102) {
current.state = 101;
} else if (current.state == 103) {
current.state = 102;
}
current.update();
action.setRedirectURL(current);
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
