Script Task Variables

Hello ,
So i am trying to make a script task to calculate loan payment using the javascript.
here’s what i tried :

var down_payment = execution.getVariable(“down_payment”);
var amount = execution.getVariable(“loan_amount”);
var years = execution.getVariable(“years”);
var payment = ((amount - down_payment ) (1.05)^5) / (years12) ;

I specify the payment as a result variable for the script.However , I have two problems :
When the script task is executed , the payment variable is shwoing like this:

“payment”: {
“type”: “String”,
“value”: “\nvar down_payment = (Integer) execution.getVariable(“down_payment”);\nvar amount = (Integer) execution.getVariable(“loan_amount”);\nvar years = execution.getVariable(“years”);\nvar payment = (Integer) ((amount - down_payment ) (1.05)^5) / (years12) ;\n\nexecution.setVariable(“payment”,payment);\n”,
“valueInfo”: {}
}

How Can i fix this and get the value of the payment variable?Is there any way to show the result variable value in camunda without setting it to a form variable after the script task?

Thank You!

@abdallah what are the Types for the down_payment, amount, and years?

edit:

How Can i fix this and get the value of the payment variable?Is there any way to show the result variable value in camunda without setting it to a form variable after the script task?

What type of forms are you using?

@abdallah

also shouldnt your payment variable read:

var payment = ((amount - down_payment )*Math.pow(1.05,5)) / (years);

Your currently have years12 which looks like a type, and your are using a ^ rather than Math.pow() (assuming i understood your notation)

Hello , I am using generated forms from camunda . Payment and down_payment are long variables.Also the years is a typo it is actually years*12.

@StephenOTT I solved the script problem , However the script returns a result and i want to show it to the user.How can i get the script result only using the api?