UI Action - "Request Approval"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2014 01:17 PM
Has anyone done something like this?
When a user clicks a UI Action, "Request Approval", it will 1) Prompt the user with a message stating all fields must be completed. 2) Sets all Fields on a particular form section to Mandatory.
Essentially, we want the user to be able to save data to a form, and come back to it, so it's a draft state, but if they submit it for approval, they will be fields from the form section that will need to be mandatory.
Any suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2014 11:24 PM
You can write an Onsubmit client script with below code:
function onSubmit() {
//Type appropriate comment here, and begin script below
var action = g_form.getActionName();
alert('You pressed ' + action);
g_form.setMandatory('rfc',true);
g_form.setMandatory('problem_id',true);
g_form.setMandatory('number',true);
}
In the above code, the action name is the Action Name you have provided in your UI action 'Request approval'.
Regards,
Bhavesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2014 11:51 PM
Hi Rachelle,
Different ways to do this, one is to perform everything within the UI action itself. Please find the code below. I have also attached a screenshot for your reference.
Name: Request Approval
Table: Your table name
Action Name: request_approval
Client: True
Form Button: True // Depends on your requirement
Onclick: runClientCode();
Script:
function runClientCode(){
alert('All fields must be completed before you can submit the form');
g_form.setMandatory('<field_1>',true);
g_form.setMandatory('<field_2>',true);
g_form.setMandatory('<field_2>',true);
gsftSubmit(null, g_form.getFormElement(), 'request_approval'); //MUST call the 'Action name' 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.update();
gs.log('Request submitted for approval successfully');
action.setRedirectURL(current);
}
You can modify the client and server functions to suit you requirement. Hope this helps.
Thanks & Regards,
Hari

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:54 PM
Hi Rachelle, Did you try the solution which I gave in my last response ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2014 01:16 AM
Hi Rachelle,
I did this in a pretty simple way.
First I created the UI Action (with a client script changing it's background colour) and the following code:
if (current.state != 3)
{
current.state = 3;
gs.addInfoMessage('*An Approval has been requested, and named approvers have been emailed with the relevant details*');
}
else
{
gs.addInfoMessage('* Approval Already Requested *');
}
gs.addInfoMessage('State : ' + current.state);
current.update();
Then, I added a "Wait Condition" before the approval activity into the workflow which waits until the state = 3, before moving on to the approval activity. It works quite well at present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2014 01:20 AM
Hi Rachelle,
Harikrishnan Vijayan suggested right solution.