0

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

null
    • Mconneen
    • 4 yrs ago
    • Reported - view

    @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. 

    options

    Next.. define the function, parameters .. and function body.   Here is an example:

    function

    Lines 111 / 113 are the "styled" return value depending on if sd is null or not. 

    Hope this helps. 

    • Nils
    • 4 yrs ago
    • Reported - view

    Thanks Mconneen! Perfect. 
    Still learning here. ;-)

    • Nick
    • 4 yrs ago
    • Reported - view

    @Mconneen... what is the code to call the above function (getZScoreText) in a formula?

    • Mconneen
    • 4 yrs ago
    • Reported - view

    @Nils

    Something like the following:

    let z:= getZScoreText(someNumberField);

    • Nils
    • 4 yrs ago
    • Reported - view

    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);
    end

    Netto := NettoPrice(Aantal, 'p/e', Korting)

    Thanks!

    • Mconneen
    • 4 yrs ago
    • Reported - view

    @Nils.. Yes.. the return value is either implied or explicit.  

    • SMoore
    • 2 yrs ago
    • Reported - view

    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
  • 3533Views