Need to Save the Form on Clicking the UI ACTION and perform the other script actions

Vayalpati
Tera Contributor

on clicking of Ui Action Button, We have to validate below mentioned fields, if not filled then need to send the error message and Abort the Action, After that if the user fill those fields the form needs to  save first and open the dailog box, but without saving it is going for the further Actions and inside the dilogbox we have another Ui Action, if we click on that Button then popup is Coming "form is may not be  submitted "cancel or Leave", if we select cancel or leave it is Submitting the form and other Actions are completing.

We have tried to use gsftSubmit and call the Action and save the Form, Saving the form but redirecting to Page

gsftSubmit(null, g_form.getFormElement(), 'ActionName');

 

Tried to Update through Business rule and script Include updating the fields still the popup is coming.

Please suggest with some Solutions

Vayalpati_2-1705018385436.pngVayalpati_3-1705018424528.png

 

 

 

 

 

2 REPLIES 2

Harsh_Deep
Giga Sage
Giga Sage

Hello @Vayalpati 

 

Please share your code

 

 

Vayalpati
Tera Contributor
function showMyForm() {
    //Get the table name and sys_id of the record
    var tableName = g_form.getTableName();
 
//STRY0159262 starts
var type = g_form.getValue('type');
var notes = g_form.getValue('u_resolution_notes');
var category = g_form.getValue('u_resolution_category');
var code = g_form.getValue('u_resolution_code');
//var groupRef = g_form.getValue('u_assignment_group_tma');
    var groupRef = g_form.getReference('u_assignment_group_tma');
 
    if (groupRef) {
        var groupName = groupRef.getValue('name');
 
        var group = new GlideRecord('sys_user_group');
        group.addQuery('name', groupName);
        group.addQuery('u_division', 'TMASUNRISE');
        group.query();
 
        if (group.next()) {
 
if((notes == '' || category == '' || code == '') && (type == 'sap_assistance' || type == 'sap_correction')){
g_form.addErrorMessage(getMessage("Please fill the Resolution Information fields to Cancel  the request"));
g_form.setMandatory('u_resolution_notes', true);
g_form.setMandatory('u_resolution_category', true);
g_form.setMandatory('u_resolution_code', true);
return false;
}
}
}
//STRY0159262 Ends
 
    //Create and open the dialog form
    var dialog = new GlideDialogForm('SAP Copy Request', tableName); //Provide dialog title and table name
    dialog.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
    dialog.addParm('sysparm_view', 'sap_cancel_and_change'); //Specify a form view
    dialog.addParm("sysparm_view_forced", "true"); //force the view to default
    dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
 
    var query = '';
 
    query += "parent=" + g_form.getUniqueValue(); //ok
    query += "^opened_by=" + g_form.getValue('opened_by'); //ok
    query += "^assignment_group=" + g_form.getValue('assignment_group'); //ok
    query += "^assigned_to=" + g_form.getValue('assigned_to'); //ok
    query += "^u_point_of_contact=" + g_form.getValue('u_point_of_contact'); //ok
    query += "^u_business_service=" + g_form.getValue('u_business_service'); //ok
    query += "^cmdb_ci=" + g_form.getValue('cmdb_ci'); //ok
    query += "^u_company_owner_group=" + g_form.getValue('u_company_owner_group'); //ok
    query += "^u_work=" + g_form.getValue('u_work'); //ok
    query += "^u_functional_scope=" + g_form.getValue('u_functional_scope'); //ok
    query += "^u_subdomain=" + g_form.getValue('u_subdomain'); //ok
    query += "^short_description=" + g_form.getValue('short_description'); //OK
    query += "^description=" + g_form.getValue('description'); //ok
    query += "^category=" + g_form.getValue('category'); //ok
    query += "^u_project_code=" + g_form.getValue('u_project_code'); //ok
    query += "^risk=" + g_form.getValue('risk'); //ok
    query += "^priority=" + g_form.getValue('priority'); //ok
    query += "^u_need_pre_acceptance=" + g_form.getValue('u_need_pre_acceptance'); //ok
    query += "^u_pre_acceptance_bpo=" + g_form.getValue('u_pre_acceptance_bpo'); //ok
    query += "^start_date=" + g_form.getValue('start_date'); //ok
    query += "^end_date=" + g_form.getValue('end_date'); //ok
    query += "^work_end=" + g_form.getValue('work_end'); //ok
    query += "^work_start=" + g_form.getValue('work_start'); //ok
    query += "^u_assigned_to_it=" + g_form.getValue('u_assigned_to_it');
    query += "^u_assignment_group_tgs=" + g_form.getValue('u_assignment_group_tgs'); //ok (onglet)
    query += "^u_assignment_group_tma=" + g_form.getValue('u_assignment_group_tma');
    query += "^u_assigned_to_tma=" + g_form.getValue('u_assigned_to_tma');
    query += "^type=" + g_form.getValue('type'); //ok  
    query += "^u_old_parent_ticket=" + g_form.getValue('number');
    if (g_form.getValue('risk') == 1 || g_form.getValue('risk') == 2) {
        query += "^u_type_of_impact=" + g_form.getValue('u_type_of_impact');
        query += "^u_justification_of_gravity=" + g_form.getValue('u_justification_of_gravity');
    }
 
 
    dialog.addParm('sysparm_query', query);
 
    var oldType = '' + g_form.getValue('type');
 
    dialog.setLoadCallback(function(iframeDoc) {
        // To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
        var dialogFrame = 'sap_cancel_and_change' in iframeDoc ? iframeDoc.sap_cancel_and_change : iframeDoc.parentWindow;
 
        //dialogFrame.g_form.removeOption('type', oldType);
 
        dialogFrame = null;
    });
 
    dialog.render(); //Open the dialog
}