Idea Portal Widget Populate Default Field Values

litchick10
Tera Guru

In the Idea Portal widget IM Create/Edit I added a field called u_epic.  However, I cannot get a default value to populate on the form.

I tried to set the value and displayValue in the code shown below that can be found under $scope.data.formModel object. No text shows up in the form field (using 'Test' below just as example)

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) || '',
 value: 'Test',
 displayValue: 'Test',
 type: 'html',
 mandatory: true,
 mandatory_filled: function () {
 return !!($scope.data.formModel._fields.u_epic.stagedValue);
 },
 isMandatory: function () {
 return true;
 }
}

 

 find_real_file.png

 

 

1 ACCEPTED SOLUTION

So looks like your HTML tinyMce editor is bound to the stagedValue.

Can you replace the staged value line in your client controller's u_epic's definition with:

stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_epic) || 'Test',

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)

 

 

 

View solution in original post

13 REPLIES 13

So it did change the value on platform UI, but not on portal. That means the client script did trigger, but for some reason couldn't set the value on the portal UI.

Can you change the UI type on your client script to "Desktop", and save it, and then try? Sometimes if there are any incompatible mobile scripts present on the code, could cause unforeseen errors. So try to toggle to all three types on the client script, and see if any works for you on the portal UI.

If the above doesn't work, from the application navigator, System Definition --> Tables, go to your idea table, and then to the epic column, and on the Default value tab on the column, set a default value at the field definition itself.

 

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)

The default value for the field definition has been set to what I want from the beginning

I tried toggling between all 3 options on the client script before telling you it didn't work.

I'm wondering if it is how I added the field to the idea portal form.

Here is the code used to add the epic field to the IM Idea Create/Edit widget:

HTML added after Description field

<! --  Added Epic Field -->                               
                          <label for="u_epic" class="field-label" title="{{::data.formModel._fields.u_epic.label}}" aria-label="{{::data.formModel._fields.u_epic.label}} "
                                 tooltip-right="true">
                                 <span class="field-decorations">
                                 <span ng-show="::data.formModel._fields.u_epic.mandatory" class="fa fa-asterisk mandatory" ng-class="{'mandatory-filled': data.formModel._fields.u_epic.mandatory_filled()}"
                                       title="${Required}"  style="padding-right: .25em" aria-label="{{data.formModel._fields.u_epic.mandatory_filled()? '${Required Filled}' : '${Required}'}}"></span>
                                 </span>
                                 {{::data.formModel._fields.u_epic.label}}
                            </label>
                            <cf-tiny-mce
                                 ng-class="(formSubmitted && !data.formModel._fields.u_epic.stagedValue) ? 'field-invalid' : ''"
                                 data-ng-model="data.formModel._fields.u_epic.stagedValue"
                                 ng-model-options="{height: '300', allow: false}"
                                 table="{{data.formModel.table}}"
                                 attachment-sys-id="-1"
                                 max-file-size="{{data._maxAttachmentSize}}">
                              </cf-tiny-mce>

 

Client Controller added at line 79

			   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) || '', 
                value: "test",
				displayValue: "test",
				type: 'html',
				mandatory: false,
				mandatory_filled: function () {
				 return !!($scope.data.formModel._fields.u_epic.stagedValue);
				 },
				 isMandatory: function () {
				 return true;
				 }
            }

Client Controller added in the _requestParams function

		requestParams.sysparm_u_epic = formFields.u_epic.stagedValue;

 

 

 

So looks like your HTML tinyMce editor is bound to the stagedValue.

Can you replace the staged value line in your client controller's u_epic's definition with:

stagedValue: ($scope.data.ideaInfo && $scope.data.ideaInfo.u_epic) || 'Test',

Thanks & Regards,

Rishabh Jha

Aavenir (http://www.aavenir.com/)

 

 

 

IT WORKED!!!

Thank you thank you thank you for all your help and patience!!!