Page 1 of 1

Onclick Event and Multiple RunPCCommand

Posted: Wed Jul 15, 2015 4:54 am
by brett.elston
Hi,

I am having a small problem with the script for an onclick event. I have a print button that needs to launch two Crystal reports. For whatever reason only the first RunPCCommand is executed. As a solution I can create multiple buttons to launch each report seperately but hoping that I am maybe just missing something obvious.

Please could you tell me where I am going wrong ? (Script below)

Best Regards

Brett

var command = "\\\\amasisprnsrv01\\CREXPORT\\crexport -u user -p password -f \\\\amasisprnsrv01\\crystal\\MROCRD.rpt -e print -d S06D632P -s DATALIB -a WSDOC1:"+get("PRTDOC1")+" -a WSDOC2:"+get("PRTDOC2")+" -a WSENV:"+get("PRTENV")+" -l";runPCCommand(command);
var command = "\\\\amasisprnsrv01\\CREXPORT\\crexport -u user -p password -f \\\\amasisprnsrv01\\crystal\\MROINVD.rpt -e print -d S06D632P -s DATALIB -a WSENV:"+get("PRTENV")+ "-a WSDOC1A:"+get("PRTDOC1")+" -a WSDOC2A:"+get("PRTDOC2")+" -l";runPCCommand(command);
pui.click('ENTER');

Re: Onclick Event and Multiple RunPCCommand

Posted: Wed Jul 15, 2015 2:50 pm
by Scott Klement
I wrote up a quick test, and it worked for me. It might be failing for you due to the pui.click() call, however?

A few thoughts:

a) Even though you can launch two PC commands, it does not wait until the first has finished. So they will be running at the same time.

b) the pui.click() may submit the screen back to the server. This might be a problem if the previous runPCCommand is still in progress because it will remove your screen from the display and re-build it, and that means it'll stop the code that's running runPcCommand

c) pui.click() does not take a key name as a parameter. So when you code pui.click("ENTER") it is looking for a widget with id="ENTER". If you are trying to replicate the behavior of the user pressing the enter key, you can just do pui.click() (with no parameter). This will submit the screen without clicking a particular widget, just as it would if the user pressed enter.

Let me know if that helps at all.

Re: Onclick Event and Multiple RunPCCommand

Posted: Thu Jul 16, 2015 4:53 am
by brett.elston
Hi Scott,

Thank you – most helpful.

I did not take into account that both commands would be run simultaneously. This causes a lock on which causes the second command to fail.
I have now tried with a setTimeout(5000), between the two executions, but it seems to have no effect. Does it continue regardless?

Re: Onclick Event and Multiple RunPCCommand

Posted: Thu Jul 16, 2015 5:02 am
by brett.elston
Sorry, it is the syntax of my seTimeout that is wrong. Providing I can execute the command, within setTimeout, is this a viable way forcing a delay?

Re: Onclick Event and Multiple RunPCCommand

Posted: Thu Jul 16, 2015 7:37 am
by brett.elston
Thank you Scott,

I think I got it with the code below.

Best Regards

Brett

var command = "\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROCRD.rpt -e print -d S06D632P -s DATALIB -a WSDOC1:"+get("PRTDOC1")+" -a WSDOC2:"+get("PRTDOC2")+" -a WSENV:"+get("PRTENV")+" -l";runPCCommand(command);
setTimeout(function(){var command = "\\\\amasisprnsrv01\\CREXPORT\\crexport -u creps -p creps -f \\\\amasisprnsrv01\\crystal\\MROINVD.rpt -e print -d S06D632P -s DATALIB -a WSENV:"+get("PRTENV")+" -a WSDOC1A:"+get("PRTDOC1")+" -a WSDOC2A:"+get("PRTDOC2")+" -l";runPCCommand(command); }, 2000);
pui.click();