Is it possible to add flash and to set focus to a journal input field?

Jan Post2
Tera Contributor

Hi,

Trying the following in a client script:

g_form.flash('incident.work_notes', "#FFFACD", -4);

g_form.getControl('incident.work_notes').focus();

 

This perfectly works on non journal input fields, but i can't get it to work on journal input fields like work notes and/or additional comments.

 

Is this at all possible, or am I missing something?

 

Regards

Jan

 
4 REPLIES 4

Mark Manders
Mega Patron

Not validated (my PDI won't wake up), but check if this works:

function onLoad() {
    // Use setTimeout to ensure the DOM is fully loaded
    setTimeout(function() {
        var workNotesField = gel('activity-stream-work_notes-textarea'); // The ID of the work_notes field
        if (workNotesField) {
            workNotesField.focus(); // Set focus to the work_notes field
        }
    }, 100); // Adjust the timeout as needed
}

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,

 

Thnx for your swift response.

 

It will be in an on change client script. In our case, when one changes the priority, they need to supply a reason by adding a work note. Hence, we want to flash the work note field and set focus to it.

 

Regards

Tried  your code Mark. No  luck!  Looks like Vancouver doesn't work with 'gel' any more, getting "onChange script error: TypeError: gel is not a function function() { [native code] }".

NS
Kilo Sage

I also faced the same issue. Looks like `flash` does not support a journal input field. Unfortunately it looks like ServiceNow forgot to mention it in their documentation: no mention in the GlideForm API 

 

@Jan Post2 did you come up with any workaround? I'm just curious.