From 0acff7163830bd1fdeefa9a97770f553c1807112 Mon Sep 17 00:00:00 2001
From: satish <satish.dvnk@vtiger.com>
Date: Sat, 17 Sep 2016 15:10:28 +0530
Subject: [PATCH] Fixes #39 - Regression: Workflow Create Entity Task failure
 after migration

---
 .../Settings/Workflows/actions/TaskAjax.php    |  2 +-
 modules/Settings/Workflows/views/EditTask.php  | 18 ++++++++++--------
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/Settings/Workflows/actions/TaskAjax.php b/modules/Settings/Workflows/actions/TaskAjax.php
index 90a9357c3..ef1ab3a45 100644
--- a/modules/Settings/Workflows/actions/TaskAjax.php
+++ b/modules/Settings/Workflows/actions/TaskAjax.php
@@ -106,7 +106,7 @@ class Settings_Workflows_TaskAjax_Action extends Settings_Vtiger_IndexAjax_View
 				foreach ($fieldMapping as $key => $mappingInfo) {
 					if (array_key_exists($mappingInfo['fieldname'], $ownerFieldModels)) {
 						if ($mappingInfo['value'] == 'assigned_user_id') {
-							$mappingInfo['valuetype'] = 'fieldname';
+							$fieldMapping[$key]['valuetype'] = 'fieldname';
 						} else {
 							$userRecordModel = Users_Record_Model::getInstanceById($mappingInfo['value'], 'Users');
 							$ownerName = $userRecordModel->get('user_name');
diff --git a/modules/Settings/Workflows/views/EditTask.php b/modules/Settings/Workflows/views/EditTask.php
index 081f967c1..bddcb9e91 100644
--- a/modules/Settings/Workflows/views/EditTask.php
+++ b/modules/Settings/Workflows/views/EditTask.php
@@ -55,16 +55,18 @@ class Settings_Workflows_EditTask_View extends Settings_Vtiger_Index_View {
 				$fieldMapping = Zend_Json::decode($taskObject->field_value_mapping);
 				foreach ($fieldMapping as $key => $mappingInfo) {
 					if (array_key_exists($mappingInfo['fieldname'], $ownerFieldModels)) {
-						$userRecordModel = Users_Record_Model::getInstanceByName($mappingInfo['value']);
-
-						if ($userRecordModel) {
-							$ownerName = $userRecordModel->getId();
+						if ($mappingInfo['value'] == 'assigned_user_id') {
+							$fieldMapping[$key]['valuetype'] = 'fieldname';
 						} else {
-							$groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']);
-							$ownerName = $groupRecordModel->getId();
+							$userRecordModel = Users_Record_Model::getInstanceByName($mappingInfo['value']);
+							if ($userRecordModel) {
+								$ownerName = $userRecordModel->getId();
+							} else {
+								$groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']);
+								$ownerName = $groupRecordModel->getId();
+							}
+							$fieldMapping[$key]['value'] = $ownerName;
 						}
-
-						$fieldMapping[$key]['value'] = $ownerName;
 					}
 				}
 				$taskObject->field_value_mapping = Zend_Json::encode($fieldMapping);
-- 
GitLab