Check if field is a specific value or empty

Mark Vancil2
Mega Guru

Using this is an IF check on a workflow, and not sure where I'm going wrong. It's not catching when the field is empty.

 

var gr = new GlideRecord("sys_user");
gr.get(current.variables.request_for.toString());
gs.warn(gr.u_jobfamily);

if (gr.u_jobfamily == 'SB') {
   answer = 'yes';
	
} 
else if (gr.u_jobfamily.nil()) {
	answer = 'yes';
}
else {
	answer = 'no';

}
1 ACCEPTED SOLUTION

Thanks for the update. However if you feel the issue is still there you can give a try with below script:

answer = ifScript();
function ifScript(){
	var gr = new GlideRecord("sys_user");
	gr.get(current.variables.request_for.toString());
	gs.warn(gr.u_jobfamily);
	
	if (gr.u_jobfamily == 'SB') {
		return 'yes';
		
	}
	else if (gr.u_jobfamily.nil()) {
		return 'yes';
	}
	else {
		return 'no';
		
	}
}

 

Regards,

Alok

View solution in original post

11 REPLIES 11

Actually, I think I'm barking up the wrong tree. I think it IS working and the problem is further down my flow.

 

I appreciate your help. I will mark your answer as correct.

Thanks for the update. However if you feel the issue is still there you can give a try with below script:

answer = ifScript();
function ifScript(){
	var gr = new GlideRecord("sys_user");
	gr.get(current.variables.request_for.toString());
	gs.warn(gr.u_jobfamily);
	
	if (gr.u_jobfamily == 'SB') {
		return 'yes';
		
	}
	else if (gr.u_jobfamily.nil()) {
		return 'yes';
	}
	else {
		return 'no';
		
	}
}

 

Regards,

Alok