Inject js script not returning output

I used inject Js script. but i m not able to get output value from javascript code even after returning it.

Hi,

Can you share your JavaScript file?

Regards,

1 Like

javascript:{

	var cpt= ["Tdkdfd45","Tdkdfd45gr","Tdkdfd45dsfsf","Tdkdfd45f4","Tdkdfd45gfdg44"];
		
			
		var i=-1;
		var j;
		t1=setInterval(f1,3000);		
		
		
		
		function f1()
		{
			i=i+1;
			document.getElementById("cptno").value=cpt[i];
			document.getElementById("fetch").click();
			
			setTimeout(f2,3000);
			
		}

		function f2()
		{
			
			alert(document.getElementById("mpt").value.toString());	
			if(i>3)
			{
				clearTimeout(t1);
			}

		}
				
}

actually uipath not working with settimeout function and is not waiting for settimeout and all.

and i have to return the value in mpt id as a string

Hi,

We need to write it as function like the following.

function (element, input) {
    // some codes
    return "result";
}

Please check the following document.

Regards,

i already done this bro…

actually settimeout function is not working in uipath.