Double message print custom script

image

how can i make only one print message? tnx in advance :blush:

:pray::pray::pray::pray:

@mycarlo try to add break; after the msgprint.

 break;

it works, but the checkbox is checked…
image

I want the checkbox is not check when not equal like the picture below…but I want only one msgprint

@mycarlo put it before the break .

what do you mean?

@mycarlo the frm.set_value… replace it just before the break .

same issue the checkbox is checked

frappe.ui.form.on(“Disposed Item”, {
check(frm){

	 for(var a=0, len1=frm.doc.items.length; a < len1;a++){
	
		 if(frm.doc.items[a].qty1 == frm.doc.items[a].qty){
		continue;
		}
		else{
		frappe.msgprint("Some Items are not equal to your Witdrawal");			
		break;	
		}				
		
	 }

}

});

this is my code

up ???

@Thukten_Dendup sir :smiling_face:

Since you are looping within for loop, it will print you multiple messages. The only option to print a single message is by introducing a flag and moving the msgprint outside for loop.

var flag = 0;
for(var a=0, len1=frm.doc.items.length; a < len1;a++){
if(frm.doc.items[a].qty1 == frm.doc.items[a].qty){
flag = 1;
}
}
if(flag){
frappe.msgprint(“Some Items are not equal to your Witdrawal”);
}

this is my code sir but not working…my trigger is checkbox

frappe.ui.form.on(“Disposed Item”, {
check(frm){
var flag =0;
for(var a=0; a<frm.doc.items.length;a++){

		 if(frm.doc.items[a].qty1 != frm.doc.items[a].qty){
	 var flag = 1;
		}
		}
		if(flag){
		msgprint('Items are not equal to your Witdrawal ' + 'row #'   + frm.doc.items[a].idx + '- '+frm.doc.items[a].item_code );
		frm.set_value("check",'');
		}				
					
				
}

});