Executing JS in process script

146 views
Skip to first unread message

sagar....@flowian.com

unread,
Dec 24, 2014, 1:22:01 AM12/24/14
to suppor...@runmyprocess.com
Hi Team,

I have one javascript an need to execute at the process level.
For that i have taken activity and keep the type to "script". I have used the uploaded js file to execute the script.
But it gives me error though the script is running very fine outside that activity.

My script is as follows ...
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function lastdaytime(endtime,mintime,maxtime)
{
var ldt=0;

if(endtime < mintime)
{
setVariable("first",1);
return 0;}

if((endtime.getDay()==0)||(endtime.getDay()==6))
{
setVariable("second",2);
return 0;
}

if(endtime > maxtime)
{
setVariable("third",3);
endtime = maxtime;
}
ldt=( endtime - mintime ) / (60000);
return ldt;

}
var a= new Date(2014,11,23,10,00,00);
var b= new Date(2014,11,23,19,00,00);
var d= new Date(2014,11,23,12,00,00);
var k=lastdaytime(d,a,b);
setVariable("V",k);
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

I don't understand why it is giving me error. I think problem is in the "if" condition.

The error message is "nullpointerexception"

Can anyone help me to sort out this problem.

Regards,
Sagar

Shobhit Tripathi

unread,
Dec 24, 2014, 6:48:55 AM12/24/14
to suppor...@runmyprocess.com
Hi Sagar,

Could you please elaborate your requirement, because you can also use JavaScript inside process (just adding script tag i.e. <@script env = "javascript">......</@script>).
Have you configured script tab. Please refer the below link for more information.



As per you are facing problem, you need to define the variable in process input activity and not in JS.
Example: var a= new Date(2014,11,23,10,00,00); 

Note: choosing type:"script" will make the activity "long running script" which is counted for usage charge. So it is not recommend, unless you really need the long running script.
You can just choose "none" and write the same scripts for collections, and you won't be charged for script executions.

Feel free to ask.

Thanks & Regards,
Shobhit
Fujitsu - RunMyProcess

sagar....@flowian.com

unread,
Dec 24, 2014, 7:09:32 AM12/24/14
to suppor...@runmyprocess.com
Hi Shobit,

First thanks for the reply.

No, I am not using the " <@script env = "javascript">......</@script>".

In the task functional tab, I have select the type as=>Script =>Javascript.

Then by selecting the url of uploaded JS file I was trying to execute the JS.

And my whole js is running in other environments. Also in the test console of RMP web-interface.

But the problem is that it is giving error in the process task. I have tried different things but of no use.

And Yes I need it to be run in the process.

Regards,
Sagar



Shobhit Tripathi

unread,
Dec 24, 2014, 7:59:26 AM12/24/14
to suppor...@runmyprocess.com
Hi Sagar,

Yes I understand this. I just wanted to know why you are using this script task.

You can also use this in input parameter of process activity (with using <@script env="javascript">....</@script>).

But if you wanted to use this with script task then you have to define the variables of your javascript in process activity input parameter fields(Please follow above post)

Hope this will help you. Please feel free to ask

Thanks & Regards,
Shobhit


Regards,
Sagar



--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/85e1a1f9-d179-470e-9e87-74a0bf84d080%40runmyprocess.com.



--
Thanks & Regards,
Shobhit
Fujitsu- RunMyProcess

sagar....@flowian.com

unread,
Dec 27, 2014, 12:39:31 AM12/27/14
to suppor...@runmyprocess.com
Hi Shobit,

I am going with your suggestion of using "<@script env="javascript">....</@script>" in input/output variable.

And now no problem with the JS. It is working fine.

Thanks for your support.

Regards,
Sagar
Reply all
Reply to author
Forward
0 new messages