UI Action cancel proposal

Community Alums
Not applicable

Hi,

I want to cancel a Standard Change Proposal without having to populate the mandatory fields e.g. Description, Business Justification and Sample Change Requests. For this i have modified the cancel proposal ui action as below. On clicking cancel proposal fields are becoming non mandatory but proposal is not getting cancelled. Can someone please help me on this.

 

function goToNew(){
    g_form.setMandatory('category',false);
    g_form.setMandatory('template_name',false);
    g_form.setMandatory('short_description',false);
    g_form.setMandatory('assignment_group',false);
    g_form.setMandatory('description',false);
    g_form.setMandatory('business_justification',false);
    g_form.setMandatory('change_requests',false);
    gsftSubmit(null, g_form.getFormElement(),'std_change_proposal_cancel');

}

if (typeof window == 'undefined')
serverSideCodeToRun();

function serverSideCodeToRun(){
new StdChangeUtils().cancelStandardChangeProposal(current.getUniqueValue());
action.setRedirectURL(current);
}
2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Community Alums 

 

I am able to do with OOTB UI Action

AGLearnNGrow_0-1727765089119.pngAGLearnNGrow_1-1727765100463.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Rajesh Chopade1
Mega Sage

Hi @Community Alums 

Could you try bellow code once:

function goToNew() {
    // Set mandatory fields to false
    var fields = [
        'category',
        'template_name',
        'short_description',
        'assignment_group',
        'description',
        'business_justification',
        'change_requests'
    ];
    
    fields.forEach(function(field) {
        g_form.setMandatory(field, false);
    });

    // Submit the form with the specified action
    gsftSubmit(null, g_form.getFormElement(), 'std_change_proposal_cancel');
}

if (typeof window == 'undefined') {
    serverSideCodeToRun();
}

function serverSideCodeToRun() {
    try {
        gs.info('Cancelling Standard Change Proposal: ' + current.getUniqueValue());
        // Call the method to cancel the standard change proposal
        new StdChangeUtils().cancelStandardChangeProposal(current.getUniqueValue());
        // Redirect to the current record
        action.setRedirectURL(current);
    } catch (e) {
        gs.error('Error cancelling Standard Change Proposal: ' + e.message);
    }
}

check the logs for errors or information that might guide further troubleshooting.

 

i hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

thank you

rajesh