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

Nope, won't allow form to save

Just try with this 

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

Got the undefined error again.  

find_real_file.png

litchick10
Tera Guru

So I think what needs to happen here is I need to retrieve the selected sys_user ID for the u_opened_for field then pass that value to the requestParams.

Does anyone know how to do that?