Idea Portal Added Fields not writing to table

litchick10
Tera Guru

I have added 4 fields to the IM Create/Edit widget for the Idea Portal.  The fields work correctly on the form but 3 of the fields are not sending the data to the back end record

The fields types in the table are Reference (u_opened_for from sys_user, u_business_unit from business_unit) & List (u_collaborators from sys_user)

find_real_file.pngfind_real_file.png

 

I'm 99% sure it is in the client controller script that the issue is occurring. I have also added all fields to the Scripted Rest API code & Script Includes needed which is why Epic Hypothesis works. 

Here is my script for 3 fields not working:

Under

$scope.data.formModel = {
_fields: {

// Add Opened for field
			u_opened_for: {
				 label: $scope.data.messages.formLabels.u_opened_for,
				 name: $scope.data.messages.formLabels.u_opened_for,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_opened_for) || '',
				 value: '',
				 displayValue: '',
				 type: 'reference',
				 mandatory: true,
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_opened_for.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				},
// Add Collaborators field
			u_collaborators: {
				 label: $scope.data.messages.formLabels.u_collaborators,
				 name: $scope.data.messages.formLabels.u_collaborators,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_collaborators) || '',
				 value: '',
				 displayValue: '',
				 type: 'list',
				 mandatory: false,
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_collaborators.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				},
// Add benefiting businesss line field
			u_business_unit: {
				 label: $scope.data.messages.formLabels.u_business_unit,
				 name: $scope.data.messages.formLabels.u_business_unit,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_business_unit) || '',
				 value: '',
				 displayValue: '',
				 type: 'reference',
				 mandatory: true,
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_business_unit.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				}		

Under

var _getRequestParams = function (formFields, widgetMode) {
var requestParams = {};

requestParams.sysparm_u_epic = formFields.u_epic.stagedValue; //works
requestParams.sysparm_u_collaborators = formFields.u_collaborators.stagedValue;//does not work
requestParams.sysparm_u_business_unit = formFields.u_business_unit.stagedValue;//does not work
requestParams.sysparm_u_opened_for = formFields.u_opened_for.stagedValue;//does not work

 Scripted Rest API - Idea Portal Management --> Idea CUD Management under Create Idea

Under

if(operation == 'create') {

ideaInfo.u_epic = requestData.sysparm_u_epic;
ideaInfo.u_business_unit = requestData.sysparm_u_business_unit;
ideaInfo.u_opened_for = requestData.sysparm_u_opened_for;
ideaInfo.u_collaborators = requestData.sysparm_u_collaborators;

 

Script Includes (IMCreateEditIdeaDataService) replaced original content with this

var IMCreateEditIdeaDataService = Class.create();

IMCreateEditIdeaDataService.prototype = Object.extendsObject(IMCreateEditIdeaDataServiceSNC, {
  
createIdea: function(ideaInfo) {
 //gs.log('ideaInfo: ' + JSON.stringify(ideaInfo), 'IdeaPortal');
 var newIdeaSysId;
 var ideaGr = new GlideRecord(this.ideaTableName);
 ideaGr.initialize();
 ideaGr.setNewGuidValue(ideaInfo.sysId); //Setting sys_id here so that to fetch related attachments
 ideaGr.module = ideaInfo.module;
 ideaGr.short_description = ideaInfo.title;
 ideaGr.idea_description = ideaInfo.description;
 ideaGr.u_epic = ideaInfo.u_epic;
 ideaGr.u_collaborators = ideaInfo.u_collaborators;
 ideaGr.u_opened_for = ideaInfo.u_opened_for;
 ideaGr.u_business_unit = ideaInfo.u_business_unit;
 if(ideaGr.canCreate()) {
 newIdeaSysId = ideaGr.insert();
 //this.updateIdeaReferencesWithCategories(ideaInfo.categoryInfo,newIdeaSysId);
 this.createM2MReferencesForIdeaAndCategories(ideaInfo.categoryInfo,newIdeaSysId);
 this.updateEditorAttachments(ideaInfo.editorImages, newIdeaSysId);
 }

return {
 'sys_id': newIdeaSysId
 };
},
});

 

1 ACCEPTED SOLUTION
19 REPLIES 19

Chander Bhusha1
Tera Guru

Hi litchick,

I believe you have used the sn-record-picker for the reference field in the HTML side.

For example

HTML:

  <sn-record-picker field="name" table="'sys_user'" display-field="'name'" value-field="'sys_id'" 
                                   search-fields="'name'" page-size="100"  >

So in I need the value selected in the reference field in client side then I will use this line:

 

var a = $scope.name.value;
alert('Name selected '+ a); //Returns the sysid of the user selected.

Then you can pass the value to server side and do the scripting there to create a record.

 

Thanks,

CB

I apologize, I'm really new at widget development, I don't understand how to transmit this data from server side. I included the entire code in the widget and please you can point to where it needs to go. 

IM Create/Edit Idea

SERVER SCRIPT

(function($sp, input, data, gs, GlideRecord) {

	data._attachmentTableSysId = options.ideaId || gs.generateGUID();
	data._maxAttachmentSize = IMCommonService.properties.MAX_ATTACHMENT_SIZE;
	data.widgetMode = options.widgetMode || 'create';
	data.showIdeaSuggestion = data.widgetMode == 'create';
//hover over 
	data.label_hover_opened_for = "Are you submitting this for another associate or yourself";
	data.label_hover_category = "Pick one or more way to categorize your idea";
	data.label_hover_collaborators = "Who can provide additional information about this idea";
	data.label_hover_business_unit = "Which business unit will most benefit from this idea";
	data.label_hover_description = "Basic description of your idea";
	data.label_hover_title = "Title of your Idea";
	data.label_hover_epic = "Detailed information on your idea, please use the template to provide info\nRequired information to create a project";
	
	
	var getModuleInfo = function() {
		var moduleId = options.moduleId || $sp.getParameter('sysparm_module_id');

		if(JSUtil.nil(moduleId))
			moduleId = IMCommonService.getModuleIdFromUserPref();
		if(JSUtil.nil(moduleId)) {
			data.hasPermissions = false;
			return;
		}

		var moduleInfo = IMCommonService.getModuleInfoFromModuleId(moduleId);
		if(moduleInfo.isValid) { 
			data.hasPermissions = true;
			data.moduleInfo = moduleInfo;
			
			data.maxLengthForTitleField = IMCommonService.getMaxLengthForField(data.moduleInfo.ideaTable, 'short_description');
		} else {
			data.hasPermissions = false;
		}
	};

	var getCategoryInfo = function() {
		var imIdeaCategory = new IMIdeaCategory();
		var categoryInfo = imIdeaCategory.getCategoryInfo(data.moduleInfo.sysId);
		if(categoryInfo.table && categoryInfo.displayField) {
			data.categoryInfo = categoryInfo;
			data.categoryOptionsList = new IMCategoryTreeBuilder(data.moduleInfo.id).buildCategoryTree().getCategoryTree();
		} else {
			data.hasPermissions = false;
		}
	};


	getModuleInfo();
	if(data.moduleInfo.sysId)
		getCategoryInfo();

	if(data.widgetMode == 'edit') {
		var imEditIdeaService = new IMCreateEditIdeaDataService(data.moduleInfo.ideaTable);
		data.ideaInfo = imEditIdeaService.getIdeaInfo(options.ideaId, data.moduleInfo.id);
	}


	if(!input) {
    data.snWebaConfig = IMCommonService.getWebaConfig() || {};

		/**
		* Messages Configuration -  Start
		**/
		var _attachmentSizeString =  "" + (Number(data._maxAttachmentSize)/1000000) + "MB";
		data.messages = {};
		data.messages.createIdeaLbl = gs.getMessage('Create an Idea');
		data.messages.formLabels = {
			'title': gs.getMessage('Title'),
			'category': gs.getMessage('Category'),
			'description': gs.getMessage('Description'),
			'u_epic': gs.getMessage('Idea Details'),
			'u_collaborators': gs.getMessage('Collaborators'),
			'u_business_unit': gs.getMessage('Benefiting business line'),
			'u_opened_for': gs.getMessage('Opened for')
			
		};

		data.messages.formErrorMsg = gs.getMessage('Error. Please fill all the required(*) fields.');
		data.messages.delAttachmentMsg = gs.getMessage('Delete Attachment?');
		data.messages.largeAttachmentMsg = gs.getMessage("Attached files must be smaller than {0} - please try again",_attachmentSizeString);
		data.messages.formDirtyMsg = gs.getMessage("Are you sure you want to leave?");
		data.messages.allCategories = gs.getMessage("All Categories");
		data.messages.categoryLevelsText = [
			gs.getMessage("this is a level 1 category"),
			gs.getMessage("this is a level 2 category"),
			gs.getMessage("this is a level 3 category"),
			gs.getMessage("this category is beyond level 3")
		];
		data.messages.categorySelectionLimitMsg = gs.getMessage('Select 1 to {0} categories', [data.moduleInfo.maxCategorySelectionLimit]);
		data.messages.saveChangesCnfrmModal =  {
			headerMsg: gs.getMessage('Warning'),
			bodyMsg: gs.getMessage('Changes you made may not be saved. Are you sure?'),
			okMsg: gs.getMessage('Ok'),
			cancelMsg: gs.getMessage('Cancel')
		};
		/**
		* Messages Configuration -  End
		**/
	}

})($sp, input, data, gs, GlideRecord);

CLIENT CONTROLLER

function ($scope, glideFormFactory, $rootScope, spModal, IdeaPortalService, $timeout, IdeaHelpers, $window, IdeaPortalConstants, spUtil, $anchorScroll, $location) {
	var a = $scope.name.value;
    $scope.alertMessages = {
        show: false
    };
    $scope.formSubmitted = false;
    $scope.forms = {};
	$scope.byPassRoute = false;
	$scope.modalConfig = {
		showModal: false
	};

	$scope.trackEvent = function(key, value, additionalValue) {
		IdeaHelpers.setWebaConfig($scope.data.snWebaConfig);
		IdeaHelpers.trackEvent(key, value, additionalValue);
	};

    if ($scope.data.widgetMode == 'create') {
        $timeout(function () {
			$scope.trackEvent(IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_CREATE.KEY, IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_CREATE.VALUE, 1);
            $scope.portal.homepage_dv = 'ideas_list&sysparm_module_id=' + $scope.data.moduleInfo.id;
            $rootScope.$broadcast('sp.update.breadcrumbs', [{
                label: $scope.data.messages.createIdeaLbl,
                url: '#'
            }]);
        });
    }
    $scope.data._categorySelectionLimit = $scope.data.moduleInfo.maxCategorySelectionLimit;
    $scope.data.formModel = {
        _fields: {
            title: {
                label: $scope.data.messages.formLabels.title,
                name: $scope.data.messages.formLabels.title,
                stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.title) || '',
                value: '',
                displayValue: '',
                mandatory: true,
                mandatory_filled: function () {
                    return !!($scope.data.formModel._fields.title.stagedValue.trim());
                },
                isMandatory: function () {
                    return true;
                }
            },
            description: {
                label: $scope.data.messages.formLabels.description,
                name: $scope.data.messages.formLabels.description,
                stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.description) || '',
                value: '',
                displayValue: '',
                type: 'html',
                mandatory: true,
                mandatory_filled: function () {
                    return !!($scope.data.formModel._fields.description.stagedValue);
                },
                isMandatory: function () {
                    return true;
                }
            },
            category: {
                label: $scope.data.messages.formLabels.category,
                name: $scope.data.messages.formLabels.category,
                mandatory: true,
                isReadOnly: function () {
                    return false;
                },
                isMandatory: function () {
                    return true;
                },
                mandatory_filled: function () {
                    return !!($scope.data.formModel._fields.category.selectedCategoryId.length > 0);
                },
                optionsList: $scope.data.categoryOptionsList,
                selectedCategoryId: ($scope.data.ideaInfo && $scope.data.ideaInfo.categoryValues) || "",
                config: {
                    maximumSelectionSize: $scope.data._categorySelectionLimit
                }
            },
// Add Epic Hypothesis field
			u_epic: {
				 label: $scope.data.messages.formLabels.u_epic,
				 name: $scope.data.messages.formLabels.u_epic,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_epic) || '<p><strong>FOR&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;customers&gt;</span></p><p><strong>WHO&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;do something&gt;</span></p><p><strong>THE&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;solution&gt;</span></p><p><strong>IS A&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;something &ndash; the &ldquo;how&rdquo;&gt;</span></p><p><strong>THAT&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;provides this value&gt;</span></p><p><strong>UNLIKE&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;competitor, current solution, or non-existing solution&gt;</span></p><p><strong>OUR SOLUTION&nbsp;</strong><span style="font-size: 10.0pt; color: gray;">&lt;does something better &ndash; the &ldquo;why&rdquo;&gt;</span></p>',
				 value: '',
				 displayValue: '',
				 type: 'html',
				 mandatory: true,
				 mandatory_filled: function () {
					 return !!($scope.data.formModel._fields.u_epic.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				},
// Add Opened for field
			u_opened_for: {
				 label: $scope.data.messages.formLabels.u_opened_for,
				 name: $scope.data.messages.formLabels.u_opened_for,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_opened_for) || '',
				 value: '',
				 displayValue: '',
				 type: 'reference',
				 mandatory: true,
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_opened_for.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				},
// Add Collaborators field
			u_collaborators: {
				 label: $scope.data.messages.formLabels.u_collaborators,
				 name: $scope.data.messages.formLabels.u_collaborators,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_collaborators) || '',
				 value: '',
				 displayValue: '',
				 mandatory: true,
				 isMandatory: function () {
				 return true;
				 },
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_collaborators.stagedValue);
				 },
			},
// Add benefiting businesss line field
			u_business_unit: {
				 label: $scope.data.messages.formLabels.u_business_unit,
				 name: $scope.data.messages.formLabels.u_business_unit,
				 stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_business_unit) || '',
				 value: '',
				 displayValue: '',
				 type: 'reference',
				 mandatory: true,
				 mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_business_unit.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
				}		
// Add other fields above here (don't forget , after }) 
        },
        table: $scope.data.moduleInfo.ideaTable,
        sys_id: $scope.data._attachmentTableSysId || -1,
        _attachmentGUID: $scope.data._attachmentTableSysId || -1
    };
    $scope.attachmentsConfig = {
        isAttachmentToolsEnabled: true,
        showAttachmentUpdatedTime: true
    };

    var flatFields = [];
    angular.forEach($scope.data.formModel._fields, function (field) {
        flatFields.push(field);
    });
    var g_form = glideFormFactory.create($scope, $scope.data.formModel.table, $scope.data.formModel.sys_id, flatFields, null, {
        uiMessageHandler: IdeaHelpers.showUiNotificationMsg
    });

    $scope.getGlideForm = function () {
        return g_form;
    };

    var attachmentParams = {
        attachmentTable: $scope.data.moduleInfo.ideaTable,
        attachmentTableSysId: $scope.data._attachmentTableSysId,
        attachmentSize: $scope.data._maxAttachmentSize
    };
    var _onFileUploadCb = function (action, attachments) {
		console.log($scope.attachments);
		if($scope.data.widgetMode == 'edit') {
			/* On edit Mode filter from editor attachments */
			var existingAttachmentsData = $scope.data.ideaInfo.attachmentsData;
			if(existingAttachmentsData && existingAttachmentsData.editorAttachments)
				attachments = IdeaHelpers.differenceInArrayOfObjs(attachments, existingAttachmentsData.editorAttachments);
		}
        $scope.attachments = attachments;
        if (action === 'added') {
			$scope.trackEvent(IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_ATTACHMENT_ADDED.KEY, IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_ATTACHMENT_ADDED.VALUE);
			$scope.setFocusToAttachment();
		}
        if (action === 'deleted') {
			$scope.trackEvent(IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_ATTACHMENT_DELETED.KEY, IdeaPortalConstants.ANALYTICS_EVENTS.CREATE_PAGE.IM_IDEA_ATTACHMENT_DELETED.VALUE);
			$scope.setFocusToAttachmentButton();	
		}
        else if (!action)
            $scope.initialAttachments = attachments;
    };
    var _onFileSizeLargeCb = function (e) {
        IdeaHelpers.showUiNotificationMsg('addErrorMessage', $scope.data.messages.largeAttachmentMsg);
    };
	var _titleValidationCb = function(e, data) {
		if($scope.formSubmitted && data === '')
			$('#sp_form_field_title').addClass('field-invalid');
		else
			$('#sp_form_field_title').removeClass('field-invalid');
		$scope.data.formModel._fields.title.stagedValue = data;
	}

    $scope.attachmentHandler = IdeaHelpers.initializeAttachmentHandler(attachmentParams, _onFileUploadCb);
    $scope.confirmDeleteAttachment = function (attachment) {
        spModal.confirm($scope.data.messages.delAttachmentMsg).then(function () {
            /*
			* on edit, just mark for delete and on save of editing changes we delete it.
			*/
			if($scope.data.widgetMode == 'edit') {
				$scope.onAttachmentDelete(attachment.sys_id, true);
				attachment.marked_for_delete = true;
			} else
				$scope.attachmentHandler.deleteAttachment(attachment);
        });
    };

    $scope.$evalAsync(function () {
        $scope.attachmentHandler.getAttachmentList();
    });

    var _isValidForm = function (formFields) {

        if(formFields.title.stagedValue.trim() === '' || (formFields.category.selectedCategoryId.length === 0) || formFields.description.stagedValue === '') {
          if(formFields.title.stagedValue.trim() === '') {
            $('#sp_form_field_title').addClass('field-invalid');
          }
          $scope.showAlert($scope.data.messages.formErrorMsg, 'danger');
          return false;
        }
		    return true;
    };

    var _getRequestParams = function (formFields, widgetMode) {
        var requestParams = {};
        requestParams.sysparm_sys_id = $scope.data._attachmentTableSysId;
        requestParams.sysparm_title = formFields.title.stagedValue;
        requestParams.sysparm_description = formFields.description.stagedValue;
		requestParams.sysparm_u_epic = formFields.u_epic.stagedValue; //works
		requestParams.sysparm_u_business_unit = formFields.u_business_unit.stagedValue;//does not work
		requestParams.sysparm_u_opened_for = formFields.u_opened_for.stagedValue//does not work
		requestParams.sysparm_u_collaborators = formFields.u_collaborators.stagedValue;//does not work
        requestParams.sysparm_category_info = {
            categoryList: formFields.category.selectedCategoryId.join(','),
            categoryTable: $scope.data.categoryInfo.table,
            categoryField: $scope.data.categoryInfo.field
        };
        if (widgetMode == 'edit') {
            requestParams.sysparm_category_info.categoryAddedList = IdeaHelpers.differenceInArrays(formFields.category.selectedCategoryId, $scope.data.ideaInfo.categoryValues);
            requestParams.sysparm_category_info.categoryRemovedList = IdeaHelpers.differenceInArrays($scope.data.ideaInfo.categoryValues, formFields.category.selectedCategoryId);
        }
        requestParams.sysparm_category_info = JSON.stringify(requestParams.sysparm_category_info);
        requestParams.sysparm_module_id = $scope.data.moduleInfo.sysId;
        requestParams.sysparm_idea_table = $scope.data.moduleInfo.ideaTable;
				requestParams.sysparm_editor_images = JSON.stringify(formFields.description.editorImagesArray);
        return requestParams;
    };

    $scope.submitIdea = function ($event) {
        $timeout(function () {
            $scope.formSubmitted = true;
            var formFields = $scope.data.formModel._fields;
            if(_isValidForm(formFields)) {
				$scope.isFormValid = true;
				var requestParams = _getRequestParams(formFields);
				$scope.showLoading = true;
				IdeaPortalService.createIdea(requestParams).then(function (response) {
									$scope.showLoading = false;
									var ideaDetails = response.data.result.ideaDetails;
									$window.location.href = '?id=view_idea&sysparm_idea_id='+ideaDetails.sys_id+'&sysparm_idea_table='+$scope.data.moduleInfo.ideaTable+'&sysparm_module_id='+$scope.data.moduleInfo.id;								
				}, function (error) {
					$scope.showLoading = false;
					console.error(error);
				});
			}
			
        });
    };

    $scope.saveEditingIdea = function ($event) {
        $timeout(function () {
            $scope.formSubmitted = true;
            var formFields = $scope.data.formModel._fields;
            if (_isValidForm(formFields)) {
                $scope.isFormValid = true;
                var requestParams = _getRequestParams(formFields, 'edit');
                $scope.showLoading = true;
				/*
				* Find number of attachments that are marked for delete in all attachments
				*/
				var _deletedAttachmentsInAllAttachments = IdeaHelpers.filterArrayOfObjsByKey($scope.attachments, 'marked_for_delete', true);
				/*
				* if marked for delete attachments are 0, ignore and save idea
				*/
				if(_deletedAttachmentsInAllAttachments.length > 0) {
					/*
					* if marked for delete attachments are more than 1, find diff between initial and deleted attachments which gives difference in attachments.
					*/
					var _diffInAttachments = IdeaHelpers.differenceInArrayOfObjs($scope.initialAttachments, _deletedAttachmentsInAllAttachments);
					/*
					* then, get the difference between marked for delete attachments and attachments in above step
					*/
					var _attachmentsDeleted = IdeaHelpers.differenceInArrayOfObjs(_deletedAttachmentsInAllAttachments, _diffInAttachments);
					/*
					* then, loop and delete one by one, if it is marked_for_delete
					*/
					_attachmentsDeleted.forEach(function(attachment) {
						if(attachment.marked_for_delete) {
							$scope.attachmentHandler.deleteAttachment(attachment);
						}
					});
				}
				IdeaPortalService.updateIdea(requestParams).then(function (response) {
					$scope.showLoading = false;
					$rootScope.$broadcast('im.view_page.edit_mode.stop');
				}, function (error) {
					$scope.showLoading = false;
					console.error(error);
				});
			}
       });
    };

    $scope.cancelEditingIdea = function ($event) {
        var _attachmentsAdded = IdeaHelpers.differenceInArrayOfObjs($scope.attachments, $scope.initialAttachments);
		/*
		* No need of taking action on deleted attachments. Because on cancel will refresh the view idea widget which will fetch all attachments that are existing.
		*/
        _attachmentsAdded.forEach(function (attachment) {
            $scope.attachmentHandler.deleteAttachment(attachment);
        });
        $rootScope.$broadcast('im.view_page.edit_mode.cancel');
    };

    spUtil.get("idea-typeahead-search", {contextual_search_sources: '44484ec187d03300c1ebd82548cb0b44', moduleInfo: $scope.data.moduleInfo, isSimiliarIdea: true, formModelTitle: $scope.data.formModel._fields.title, limit:10, maxLength: $scope.data.maxLengthForTitleField}
			  ).then(function(response) {
      $scope.data.ideaTypeaheadSearch = response;
    });
	
	var _isFormDirty = function() {
		var formFields = $scope.data.formModel._fields;
		if($scope.data.widgetMode == 'create') {
			if ($scope.forms.createForm.$dirty) {
                if (!$scope.isFormValid)
                    return true
            }
		} else if($scope.data.widgetMode == 'edit') {
			if (formFields.title.stagedValue != ($scope.data.ideaInfo && $scope.data.ideaInfo.title) || (formFields.category.selectedCategoryId.length != ($scope.data.ideaInfo && $scope.data.ideaInfo.categoryValues.length)) ||
                (formFields.description.stagedValue != $scope.data.ideaInfo.description)) {
                if (!$scope.isFormValid)
                    return true
            }
		}
		return false;
	}

    $window.onbeforeunload = function () {
        if(_isFormDirty())
			return $scope.data.messages.formDirtyMsg;
    };

    var _onImagesAddedInEditor = function (event, imagesData) {
		$scope.data.formModel._fields.description.editorImagesArray = imagesData; 
    };

    $scope.showAlert = function (msg, type) {
				
        $scope.alertMessages.type = type;
        $scope.alertMessages.msg = msg;

        $timeout(function () {
            $anchorScroll('im-alert');
        });
    };
	
	var _onLocationChangeStart = function(event, next, current) {
		if(!$scope.byPassRoute && _isFormDirty()) {
			event.preventDefault();
			var confirmModalCtrl;
			$scope.modalConfig.opts = {
				size: 'sm',
				title: $scope.data.messages.saveChangesCnfrmModal.headerMsg,
				text: '<div class="text-content"><div class="my-modal-text"></div>'+$scope.data.messages.saveChangesCnfrmModal.bodyMsg+'</div>',
				okTxt: $scope.data.messages.saveChangesCnfrmModal.okMsg,
				cancelTxt: $scope.data.messages.saveChangesCnfrmModal.cancelMsg,
				okBtnClass: 'btn-danger',
				ok: function() {
					$scope.byPassRoute = true;
					$location.search(next.split('?')[1]);
					confirmModalCtrl.close();
				},
				afterOpen: function(ctrl) {
					confirmModalCtrl = ctrl;
				},
				afterClose: function() {
					$scope.modalConfig.showModal = false;
					confirmModalCtrl = null;
					$scope.modalConfig.opts = null;
				}
			};
			$timeout(function() {
				$scope.modalConfig.showModal = true;
			});
		}
	};

    /**
     * Event Listeners
     */
    $scope.$on('dialog.upload_too_large.show', _onFileSizeLargeCb);
	$scope.$on('similiar.idea.title.search', _titleValidationCb);
	$scope.$on('cf.editor_attachments.file_exceeded', _onFileSizeLargeCb);
    $scope.$on('cf.editor.image_array', _onImagesAddedInEditor);
	$scope.$on('$locationChangeStart', _onLocationChangeStart);
}

 

Hi litchick,

Can you share the html code as well from where you are passing the values. Need to check the opened by field in html side

Thanks,

CB

And one more thing 

Can you try putting the alert as 

alert('Opened by '+ JSON.stringify($scope.u_opened_for));

in the part of client controller where you have mention comment as this is not working 

there just put this alert and let me know what is the value you are getting there.

 

 

 

Thanks,

CB