How to make 'Revert to New' UI Action available at 'Scheduled' State on Change Request Form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2019 01:51 PM
Hki,
We got a requirement to include 'Revert to New' button to visible for Scheduled State on change Request form. At present, the 'Revert to New' is available once the stage reaches to Asses and not available for later states.
How can I make changes to include 'Revert to New' at the stage of 'Scheduled State' ? So, that if the customer forget to add any information, he can go back to New State and will add the data.
Script Include:
revertToNewCondition: function(current){
var type = current.type;
var state = current.state;
if(((type=='emergency')&&(state=='-3')) ||((type=='normal')&&(state=='-4')) || ((type=='expedited')&&(state=='-4')))
return true;
else
return false;
},
deleteAssessment_revertnew: function(current){
var metType = gs.getProperty('u_changerisk_assessment_type').toString();
var gr1 = new GlideRecord('asmt_assessment_instance');
gr1.addQuery('metric_type',metType);
gr1.addQuery('state','complete');
gr1.addQuery('task_id',current.sys_id);
gr1.query();
if(gr1.next())
{
if(current.type == 'expedited'){
current.type = 'normal';
current.update();
}
var gr = new GlideRecord('asmt_metric_result');
gr.addQuery('instance', gr1.sys_id);
gr.query();
while(gr.next()) {
{
var gr2 = new GlideRecord('asmt_assessment_instance_question');
gr2.addQuery('instance', gr1.sys_id);
gr2.query();
while(gr2.next()) {
gr2.deleteRecord();
}
gr.deleteRecord();
}
gr1.deleteRecord();
}
}
},
UI Action: Revert to New
Condition: (gs.hasRole('u_change_admin') || gs.hasRole('itil')) && new U_changeutils() .revertToNewCondition(current)
revertToNew(current);
action.setRedirectURL(current);
function revertToNew(changeRequestGr) {
var workflw;
var users = changeRequestGr.u_uat_name_qa_approvers;
changeRequestGr.setWorkflow(false);
var type = changeRequestGr.type;
new Workflow().cancel(changeRequestGr);
var ap = new U_changeutils().cancelApproval(changeRequestGr,users);
var gr = new GlideRecord('wf_context');
gr.addQuery('id',changeRequestGr.sys_id);
gr.query();
while(gr.next())
{
workflw=gr.workflow_version.workflow;
gr.deleteRecord();
}
new U_changeutils().deleteAssessment_revertnew(changeRequestGr);
var changeRequest = new ChangeRequest(changeRequestGr);
changeRequest.setNew();
new Workflow().startFlow(workflw,changeRequestGr);
if (!changeRequest.changesToNew()){
gs.addErrorMessage(gs.getMessage('State Model for {0} changes does not allow reverting change from {1} state', [changeRequest.getValue('type'), changeRequest.getDisplayValue('state')]));
return;
}
changeRequest.type = 'normal';
changeRequest.update();
}
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2020 03:48 AM
Hi Nani,
Could you try this code:
Condition: (gs.hasRole('u_change_admin') || gs.hasRole('itil'))&¤t.state==-2&& new U_changeutils() .revertToNewCondition(current)
Please do Mark correct and helpful based on impact.
Regards,
Arvind
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 06:43 AM
Hi,
did you able to solved this issue? currently having an issue reverting state to New when the change request is in "Scheduled" state. Thank you!