nested if statement making me crazy

walshy
Giga Expert

I have some fields that I need to hide on the loading of the form dependent on the user logged in. However it is conditional of a field status also. I thought I would nest the IF statements within an IF statement but I cant get it to work. 

function onLoad() {

	
	// set each field to off for each musician
	g_form.setDisplay('u_rating_andy',false);
	g_form.setDisplay('u_rating_candice',false);
	g_form.setDisplay('u_rating_dave',false);
	g_form.setDisplay('u_rating_john',false);
	g_form.setDisplay('u_rating_kylie',false);
	g_form.setDisplay('u_rating_martin',false);
	g_form.setDisplay('u_rating_michael',false);
	g_form.setDisplay('u_rating_nick',false);
	
	if(g_form.getValue('u_song_satus') == '1'){
			
	if(g_user.userID == '5d2f062f4feca30030b28ab18110c7c0'){          //sys id of ANDREW user record
		g_form.setDisplay('u_rating_andy',true);                            // ANDY field
	}else if (g_user.userID == '112fc22f4feca30030b28ab18110c76c'){   //sys id of DAVE record
		g_form.setDisplay('u_rating_dave',true);                            // DAVE field
	}else if (g_user.userID == '1d2fc22f4feca30030b28ab18110c76a'){   //sys id of JOHN record
		g_form.setDisplay('u_rating_john',true);                            // JOHN field
	}else if (g_user.userID == '512f062f4feca30030b28ab18110c7bd'){   //sys id of KYLIE record
		g_form.setDisplay('u_rating_kylie',true);                           // KYLIE field 
	}else if (g_user.userID == '592f062f4feca30030b28ab18110c7bf'){   //sys id of MARTIN record
		g_form.setDisplay('u_rating_martin',true);                          // MARTIN field 
	}else if (g_user.userID == '552f062f4feca30030b28ab18110c7be'){   //sys id of MICHAEL record
		g_form.setDisplay('u_rating_michael',true);                         // MICHAEL field 
	}else if (g_user.userID == '192fc22f4feca30030b28ab18110c768'){   //sys id of NICK record
		g_form.setDisplay('u_rating_nick',true);                            // NICK field 			
	}else if (g_user.userID == '84806a6f4fc1674030b28ab18110c7c5'){   //sys id of CANDICE
		g_form.setDisplay('u_rating_candice',true);                         // CANDICE field
	}
	}else {
			g_form.setDisplay('u_rating_andy',false);
			g_form.setDisplay('u_rating_candice',false);
			g_form.setDisplay('u_rating_dave',false);
			g_form.setDisplay('u_rating_john',false);
			g_form.setDisplay('u_rating_kylie',false);
			g_form.setDisplay('u_rating_martin',false);
			g_form.setDisplay('u_rating_michael',false);
			g_form.setDisplay('u_rating_nick',false);
		}
}

I need the rating field to only show when the user is logged in, and only when the u_song_status is new (1). 

I'm just getting myself tied up in knots. 

Suggestions, wonderful people? 

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

If you need this on portal make sure UI type is set to all or Both

Also hide it onload script and create onchange script on song u_song_satus (status is misspelled) field to show rating fields.

View solution in original post

2 REPLIES 2

Mike Patel
Tera Sage

If you need this on portal make sure UI type is set to all or Both

Also hide it onload script and create onchange script on song u_song_satus (status is misspelled) field to show rating fields.

dang it, 

It was just the spelling.... 

Thank you for the sanity check!