How to get values from hidden fields on a form?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2019 06:21 AM
I looked at this https://community.servicenow.com/community?id=community_question&sys_id=b7480faddb1cdbc01dcaf3231f9619b3&view_source=searchResult
I am using an onChange script and I put
g_form.setDisplay('sys_created_by', false);
in the isLoading part of the script, but it shows up for a second then disappears. I would rather it not show up at all. So does anyone know how to do the ajax call or knows a way to completely hide it from showing up on the form because the users will complain if they see it pop up for a second and disappear hahah

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2019 06:26 AM
This is what I have right now. It's just a script to look for if the user is a part of an integration and to make assigned to mandatory based on that, but I need access to the sys_created_by field. I was using opened_by, but I feel like there could be some instances where these aren't the same.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
g_form.setDisplay('sys_created_by', false);
return;
}
//g_form.setMandatory('assigned_to', true);
if (g_form.getValue("parent") != "") {
var openedBy = g_form.getReference('sys_created_by', checkEmail);
return;
}
jslog("hit the mandatory");
g_form.setMandatory('assigned_to', true);
}
function checkEmail(openedBy) {
//open = openedBy.email.toString();
jslog(openedBy.internal_integration_user);
if ((openedBy.internal_integration_user) == "true"){
jslog("made it");
g_form.setMandatory('assigned_to', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2019 07:04 AM
Hi,
Please see the below link. Maybe it's helpful for you.
Thanks,
PKG