How to get values from hidden fields on a form?

Mitch Moses
Giga Expert

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

2 REPLIES 2

Mitch Moses
Giga Expert

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);
    }
   
   
}

Prins Kumar Gup
Giga Guru

Hi,

Please see the below link. Maybe it's helpful for you.

https://community.servicenow.com/community?id=community_question&sys_id=b7480faddb1cdbc01dcaf3231f96...

Thanks,

PKG