UI Action - "Request Approval"

rsanon
Tera Contributor

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?

9 REPLIES 9

Mark Laucus
Giga Guru

It sounds like you are working on a record type like a change that is just using form values and not variables.   If this is true you can set the values to read only a number of ways.   The can be completed by using either a UI policy or data policy.   Each has their own benefits and challenges.   You would look at   the value that changes when it is approved and when that happens the policy becomes active.   Hopefully this should help start you off on the changes.


domaners
Kilo Guru

Hi Rachelle,



You should set up your UI Policies so that they only make fields mandatory on an "Awaiting Approval" state. Whilst in the Draft state, ensure that no fields are mandatory. Then, create a UI Action named "Submit For Approval" or something similar. Tick the Client field in the UI Action, then add code as follows:



function setApproval() {


    g_form.setValue('state', 'awaiting_approval');


    g_form.save();


}



Of course, you should also add setApproval() on the Onclick field. On the second line of the script, replace state with the name of your state field and awaiting_approval with the choice value of the desired state. Now, when the user opens a record, they will be able to add as much or as little into the record as they wish, then save and come back if they need to. When the Submit For Approval button is clicked, the Macro will flick the state to awaiting_approval, at which point the mandatory fields will be enforced, a popup will tell the user to fill in the required fields and then they must complete before submitting the final time.


rsanon
Tera Contributor

Hi Adam,


Sounds like it would be easier to create UI policies to ensure the appropriate fields are mandatory at the appropriate times. And use the UI Action to enforce the UI polices. Currently the UI Action "Submit For Approval" contains this piece of code:



                            action.setRedirectURL(current);


                            current.approval='requested';


                            current.state = '9';


                            current.update();



What should I do to get there? Replacing with the following below, selecting Client and putting setApproval()   on the OnClick field does nothing. the page just stays there... any ideas?



function setApproval() {


    g_form.setValue('state', 'awaiting_approval');


    g_form.save();


}


rsanon
Tera Contributor

Any ideas?