17 views

Description

An onChange script using g_form.setValue() to set both Additional Comments and Work Notes sets only 'Worknotes' but not 'Additional Comments' when this is placed above the work notes field.

If text is entered into a collapsed journal field, like Additional Comments / Work Notes collapsed to only show one input text box, prior to the field being set to mandatory (i.e. by a client script), the 'hasChanged' flag is not triggered, causing updates to fail with the message:

'The following mandatory fields are not filled in'

 

 

Steps to Reproduce

 

--------------------------------------------------------------------------------------------------------------------
1. Create an onChange client script for the State field on [sc_task] to set 'work_notes' to mandatory:

Table
: Catalog Task
UI Type: All
Type: onChange
Field Name: State
Script:

if (newValue != oldValue) {
g_form.setMandatory("work_notes", true);
} else {
g_form.setMandatory("work_notes", false);
}

2. Ensure the Additional Comments and Work Notes fields are on the [sc_task] form.
3. Load the form with the journal fields collapsed to only show the work notes field
4. Enter some text in the field and change the value of State. If trying to save the form will throw the error 'The following mandatory fields are not filled in'.
5. Repeat steps 3-4, but expand the journal fields before adding text to work_notes. The form will save.




-----------------------------------------------------------------------------------------------------------------
1. Create an onChange client script on the incident short description field like the example below:

Table: incident
UI Type: All
Type: onChange
Field Name: Short Description
Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var txt_c = 'Comment ' +newValue;
var txt_w = 'WorkNotes ' + newValue;
g_form.setValue('comments',txt_c);
g_form.setValue('work_notes',txt_w);
g_form.save(); 
}

2. Open an incident record
3. Open the form layout
4. Check if the Work Notes field is above the Additional Comments field
5. Change the short description and save the record for the following scenarios:
5.a. Keep the Journal_input fields "expanded" 
5.b. Journal_input fields are "collapsed", "work_notes" is alone seen in the screen
5.c. Journal_input fields are "collapsed", "comments" is alone seen in the screen
6. For all the above scenarios, you should be able to see Comments and Worknotes updated correctly
7. Now, open the Form Layout and move the 'Additional Comments' field above the 'Work Notes' field
8. Change the short description and save the record for the following scenarios:
8. a. Keep the Journal_input fields "expanded"
8.b. Journal_input fields are "collapsed", "work_notes" is alone seen in the screen
8.c. Journal_input fields are "collapsed", "comments" is alone seen in the screen

Observe the work notes and additional comments do not get updated when the journal fields are collapsed, and the 'Additonal comments' field is seen stand-alone on the form, while the Form Layout has the 'Additional Comments' field above the 'Work Notes'.

Workaround

This problem is fixed in London. On earlier versions, if intended to stay in UI16, the workaround consists in creating a new User Preference [sys_user_preference] as follows: 

Name: glide.ui.activity_stream.multiple_inputs 
System: True 
Type: true/false 
Value: true 
 
This will make sure the work_notes and comments fields are always displayed separately, and will not cause this issue.
 
 

Related Problem: PRB1196249

Seen In

Jakarta Patch 3
Jakarta Patch 5

Intended Fix Version

London

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-06-15 06:03:13
Published:2018-06-12