Skip navigation
Bruce079
Currently Being Moderated

Function call in FormCalc

Sep 5, 2012 9:51 AM

I am trying to call a function (type4) from within a FormCalc exit event:

 

if ($.rawValue <> "2") then

     type4.validate()

endif

 

But when I run the form, I get an error saying that the "script does not have a method 'validate'."

 

My function definitely does have a method called 'validate', see below:

 

function validate() {

     [...]

}

 

Can anyone help me identify what I'm doing wrong? Thanks for your help.

 

--Bruce

 
Replies
  • Currently Being Moderated
    Sep 5, 2012 10:21 AM   in reply to Bruce079

    Hi,

     

    I beleive validate() is a reserved method, so you should rename your function into validateObj() or so.

    And when calling a function, the syntax looks like:

     

    if ($.rawValue <> "2") then
         validateObj()
    endif
    

     

    In contrast to JavaScript FormCalc can only call functions which have been declared before the function call.

    Just an example.

    This script works, because the function is declared before it's called.

     

    func alert(msg) do
              $host.messageBox(msg)
    endfunc
     
    if ($ < 2) then
              alert("value to small")
    else
              alert("value ok")
    endif
    

     

    but this script fails, because the function call points to a function which has not be declared yet.

     

    if ($ < 2) then
              alert("value to small")
    else
              alert("value ok")
    endif
     
    func alert(msg) do
      $host.messageBox(msg)
    endfunc
    
     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 11:58 AM   in reply to Bruce079

    Hi,

     

    the XFA spec states that a script can only reference a script in a document variable (alias script object), if it uses the same contentType (alias scripting language).

    That's why you cannot call a JavaScript function from FormCalc.

     

    http://partners.adobe.com/public/developer/en/xml/xfa_spec_3_3.pdf#pag e=377

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points