Unable to unhide fields from Custom Client Script

Hi,

I am stuck with a very peculiar situation, my client side script is doing something which has no valid reason in my limited knowledge. My client side script works fine with v4 in un-hiding the fields but in v5 its unhiding only fields in a given section.

Basically there are fields in 2 sections and only fields of one section are showing after the custom script execution. The fields in the 2nd section are not showing at all after the execution of the script.

I have checked that the execution of the script is happening but the fields are not showing.

The link to the custom client script is here: https://gist.github.com/adityaduggal/6535027#file-item-client-script-txt-L99

Now the line 99 is executing well and unhiding the fields but the fields in line 100 are not showing as they are in a different section in form.

Is there something I am missing?.. surely, but what?

Just trying to take a stab at this. Looking at function sm1 and sm2… shouldnt the 2nd parameter of toggle_display be “true” instead of “tt”? tt seems to be your tool_type field. Similarly for toggle_reqd?

function sm2(fd1,fd2,tt){
	frappe.msgprint("sm2");
	for (var i in fd1){
		cur_frm.toggle_display(fd1[i],true);
		cur_frm.toggle_reqd(fd1[i],true);
		cur_frm.toggle_display(fd2[i],true);
	}
}

Hi, how you called the sm2 function ?..

@bohlian I have tried with true as well but it is not working as well
There seems to be something which is conflicting with sm2 function but I can’t seem to figure out the problem.

@bobzz_zone You can check the full gist, its quite evident from there as to how I have called the function sm2

It turns out that the default option in the switch case was being called. Removing the default case does resolve the issue but I am still not able to find the reason why the default option is being called.

https://gist.github.com/adityaduggal/6535027#file-item-client-script-txt-L309

Ping: @anand I think you could shed some light as to why the default option is being called even when the other options are executed.

The reason I always prefer if..else to switch :smile:

But I guess in case of multiple if...else the performance of switch is far better…I might be wrong but.