- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 01:19 PM
I need to set a UI Action on a form that asks why a certain action was done. I have successfully got the answer, but how do I get it back to server for use?
I have a form button called Reject, action name RejectAN, with Client box checked, and OnClick set to runClientCode();. Below is my script:
//Client-side 'onclick' funciton
function runClientCode(){
var answer=prompt('Please provide a justification for rejecting this request.');
if (answer!=null)
{
gsftSubmit(null, g_form.getFormElement(), 'RejectAN');
}
else
{
return false;
}
}
//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_approval='rejected';
current.u_work_notes="Rejected because " + answer;
current.update();
}
Code runs successfully, but answer is coming back with null. Any ideas?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 01:22 PM
Generally when I do this type of thing, I have to do it by setting the value of a field on the form and then it will be available to you in the server script via current.u_field_name. So you may have to add a new field to your table in order to collect your data. If you don't want it visible, you can hide it with a UI Policy.
and in your client script part, right above the gsftSubmit line, put
g_form.setValue('u_field_name', answer);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:02 PM
It would, but unfortunately I am using work notes for another purpose. Although Jon's solution required another field, it work for me. Thanks for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 01:35 PM
Try this
//Client-side 'onclick' funciton
function runClientCode(){
var answer=prompt('Please provide a justification for rejecting this request.');
if (answer!=null) {
var msg = "Rejected because " + answer;
g_form.setValue("work_notes", msg);
gsftSubmit(null, g_form.getFormElement(), 'RejectAN');
}
else {
return false;
}
}
//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_approval='rejected';
//current.u_work_notes="Rejected because " + answer;
current.update();
action.setRedirectURL(current);
}
Let me know if it worked for you
Brent
P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.