Where to write a global function
I have to make a calculation: Total = Qty * price -/- discount.
I know i can make the Total a calculated field but you don't need to fill the price or discount.
So if Qyt or discount changes I want to call a global function.
Actually it doesn't matter because I want to understand the Function abilities.
I put the function in the Qty afterupdate trigger and called the function. That works.
But calling that function from Discount its not regonized. ;-(
So where is the place to put a function if you want to use it again. ;-)
7 replies
-
@Nils... To answer the question ... "where is the place to put a function if you want to use it again?: .... First go into admin mode (the wrench icon)... Then click on the database name to bring up admin view.. and click Options.
Note you will see a "global scripts" area.. click on that.
Next.. define the function, parameters .. and function body. Here is an example:
Lines 111 / 113 are the "styled" return value depending on if sd is null or not.
Hope this helps.
-
Thanks Mconneen! Perfect.
Still learning here. ;-) -
@Mconneen... what is the code to call the above function (getZScoreText) in a formula?
-
@Nils
Something like the following:
let z:= getZScoreText(someNumberField);
-
Perfect. Its already working for me. I also found that the last variable is what is given back from a function.
function NettoPrice(qty : number,pe : number,discount : number) do
"-- Hello is fake to test output function --"
let d := "Hello World";let c := qty * pe * (1 - discount / 100);
endNetto := NettoPrice(Aantal, 'p/e', Korting)
Thanks!
-
@Nils.. Yes.. the return value is either implied or explicit.
-
How would I create a Global Script Variable for a date format?
For example, if I have a field named Birthday and if I call a global variable, how do I get it to format that date the way I could like? Could I do something like
GlobalVariable(Date) to get output of MM/DD/YYYY? If so, how do I set this?
TIA!
Content aside
- 2 yrs agoLast active
- 7Replies
- 3566Views