Forcing an HTML field to update

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2018 03:01 PM
Hello,
I have an HTML field that contains some <select> boxes in it that we are deploying through the Service Portal. Getting these select boxes to save their selections is turning into a nightmare, and I don't understand why.
I was able to get this to work on the normal form view by setting up an onchange script which sets the 'selected' attribute of the options within the selections. This seems like it's working on the service portal as well - the <options> have the attribute added to them - but when on the Service Portal page these changes don't seem to flag the field as changed or dirty, and so it the changes aren't saved. If I also change some of the text within the HTML field, the changes I've made to the select boxes saves perfectly fine.
This leads me to believe that if I can find some way to force the form to always update the field in question, or change the flag of the field to updated, or dirty, or whatever it is that the form submission function is looking at to decide that my field has changed, that I can get these selections to save. I haven't had any luck finding a way to do this anywhere. There is a way to force the whole record to update it seems, but not force a specific field to update.
Any help with this would be greatly appreciated, I have spent a lot of time on this already, and I just can't get anywhere.
Thank you,
-John
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2018 03:05 PM
On the server side, you can pass a `.setForceUpdate(true)`
Another option, would be to set the sys_updated_on to now
Further Reading: https://blog.jacebenson.com/GlideRecord/#setforceupdate

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2018 04:46 PM
Hi Jace - I think these ideas are headed in the right direction, but my form still does not believe the individual HTML fields have been updated just because the form record has been.
Do you know any equivalent to .setForceUpdate(true) that works at the field level?
Thank you,
-John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2018 05:10 PM
GlideForm does have a modified property and modifiedFields property. You could try setting modified to true and adding the control name with a value of true to the modifiedFields property:
g_form.modified = true;
g_form.modifiedFields[<control name>] = true;
This is only on the frontend, though, so I'm not sure how useful that would be. Can you provide a slimmed down example of how someone could replicate this issue?
For what it's worth, the DOM onchange event will not fire unless a user interacts with the field (see: https://developer.mozilla.org/en-US/docs/Web/Events/change). So the option would have to be selected and blurred, I believe.