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

I tried adding it before return form; after return form; and after the function closing }

none of these options worked. I'm using "Test" instead of full text just to try and get it to work.

find_real_file.png

Hi,

I don't see any event handlers for form load on your client controller. You can try to create an onLoad client script, and in that script, set the value using: g_form.setValue('u_epic', 'your default_value');

If you don't want to create a client script, you'd need to look for the event that gets emitted/broadcasted at form load, and try to set the value there, using the same g_form.setValue method.

Otherwise, in your client controller, try replacing your $scope.getGlideForm function with the below snippet, and see if that works.

$scope.getGlideForm = function () {
    $timeout(function () {
        g_form.setValue('u_epic', 'Test');
        g_form.setDisplayValue('u_epic', 'Test');
    });
    return g_form;

 };

 

Thanks & Regards,

Rishabh Jha

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

Adding the code above to the existing widget client controller didn't work.

How do I add an on load client script for a portal. I know how to do it for a regular form but not sure on the idea portal. 

Client script are defined on a table. You'd need to select the table where your ideas are stored, and where you have this new field getting added to.

Make sure you select the UI Type as "All" on the client script, and the type as "onLoad".

 

Thanks & Regards,

Rishabh Jha

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

Did not work.  Changed Form value in Native ServiceNow Form but did not populate default value in Idea Portal maybe I added to wrong place