- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 10:56 PM
Hi everyone,
I need to create a UI action which changes my state backward on my approval form.
eg. if the state is Authorize it should change it to New.
How to achieve it?
please describe!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2016 07:46 AM
Hi Anup,
I could write down a UI action code for you which on click would satisfy your requirements (I had the code tested fully, works fine):
Since the approver will initiate the process so we need to make the Button on Approval [sysapproval_approver] table.
In the "Condition" field you can give your own condition according to convenience.
I have done this for a change request approval.
The code below :
- function referBack(){
- if (g_form.getValue('comments') == '') {
- // Remove any existing field message, set comments mandatory, and show a new field message
- try {
- g_form.hideFieldMsg('comments');
- } catch(e) {}
- g_form.setMandatory('comments', true);
- g_form.showFieldMsg('comments', getMessage('Please enter a comment why would you like to refer back'), 'error'); // If you want the approver to describe the changes he needs
- return false; // Abort submission
- }
- gsftSubmit(null, g_form.getFormElement(), 'refer_back'); // MUST call the 'Action name' set in this UI Action
- }
- // Code that runs without 'onclick'
- if (typeof window == 'undefined')
- serverReopen();
- function serverReopen() {
- var chg = new GlideRecord("change_request");
- chg.addQuery('sys_id' , current.getValue('sysapproval'));
- chg.query();
- if(chg.next())
- {
- chg.state = 1; //changing the state of change req back to 'Open' from 'Approval Requested'
- current.state = 'not requested'; // you might want to change the state of approval in the sysapproval_approver table from "requested" to "Not requested"
- }
- chg.update();
- current.update();
- gs.addInfoMessage(gs.getMessage("Request is referred back for changes")); // user friendly msg on success
- action.setRedirectURL(current);
- }
Copy paste this code and do your necessary changes.
Below screenshot shows error msg when approver tries to click on Refer Back button without any comments :
Below screenshot shows success msg and changes the state to not yet requested :
You can also notice that the "Refer Back" button is gone since it is already referred.(we don't need the button now. Do we?)
Happy working Anup. Please let me know your doubts if any.
Also please mark my answer correct if it fulfills your requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 11:02 PM
Hi Anup,
Could you please let us know on what conditions do you want to change back the approval? This is just for my understanding. Please elaborate !
Thanks,
Arnab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 11:33 PM
Hi Arnab,
The condition is simple.For ex-> Suppose an approval is triggered when my change moves from access to Authorize state.
The approver before approving finds that some fields needs to corrected or certain changes needs to be done on the form. So, he clicks the button (Refer Back....the UI action which I need) which directs him back to the New state of the form and then the user sets in new values or does the rectification as required.
The UI action(button) when clicked should trigger a notification simultaneously, which will inform the user that certain changes needs to be done.
Thanks,
Anup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 11:38 PM
Hi Anup
I feel this can be done via Workflow, the user should reject the Change and on Rejection you can roll back(use the activity) the change to earlier stage.
Regards
Avinash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2016 11:45 PM
Hi Avinash,
Yes it could be achieved through workflow.
But there a business requirement that this button should be visible on the approval form for referring back.
Thanks,
Anup