diff --git a/layouts/v7/modules/Settings/Workflows/resources/Edit.js b/layouts/v7/modules/Settings/Workflows/resources/Edit.js index 5542b933f6d20f67380419e88a3fe760159e6f25..fa768106f00f1c639d86c75f9ceab54b72d4c662 100644 --- a/layouts/v7/modules/Settings/Workflows/resources/Edit.js +++ b/layouts/v7/modules/Settings/Workflows/resources/Edit.js @@ -424,6 +424,28 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", { }); }); }, + + getParams: function (form, taskType) { + var preSaveActionFunctionName = 'preSave' + taskType; + if (typeof this[preSaveActionFunctionName] != 'undefined') { + this[preSaveActionFunctionName].apply(this, [taskType]); + } + var params = form.serializeFormData(); + + //when using the VTCreateEntityTask + //we avoid sending individual fieldmapping inputs as part of the request because + //they will be already present as json in the "field_value_mapping" hidden input + //and we want to avoid requests conflicts when doing server-side validation of individual fields such as parent_id in HelpDesk module. + if (taskType == 'VTCreateEntityTask') { + let mappingInputs = jQuery('#save_fieldvaluemapping').find('input.inputElement'); + mappingInputs.each(function(index) { + let fieldName = $(this).attr('name'); + delete params[fieldName]; + }); + } + return params; + }, + registerSaveTaskSubmitEvent: function (taskType) { var thisInstance = this; var form = jQuery('#saveTask'); @@ -433,12 +455,9 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", { // to Prevent submit if already submitted jQuery("button[name='saveButton']", form).attr("disabled","disabled"); var record = jQuery('#record').val(); + var params = thisInstance.getParams(form, taskType); + if(!record) { - var preSaveActionFunctionName = 'preSave' + taskType; - if (typeof thisInstance[preSaveActionFunctionName] != 'undefined') { - thisInstance[preSaveActionFunctionName].apply(thisInstance, [taskType]); - } - var params = form.serializeFormData(); var clonedParams = jQuery.extend({}, params); clonedParams.action ='ValidateExpression'; clonedParams.mode ='ForTaskEdit'; @@ -478,12 +497,7 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", { }); } else { - var preSaveActionFunctionName = 'preSave' + taskType; - if (typeof thisInstance[preSaveActionFunctionName] != 'undefined') { - thisInstance[preSaveActionFunctionName].apply(thisInstance, [taskType]); - } form.find('[name="saveButton"]').attr('disabled', 'disabled'); - var params = form.serializeFormData(); app.helper.showProgress(); app.request.post({data:params}).then(function (error, data) { app.helper.hideProgress();