Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 8 of 8

Thread: Creating variables in JavaScript, reusing inside RAD expressions

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default Creating variables in JavaScript, reusing inside RAD expressions

    Hello, everybody

    I'm actually creating an interface between SC6 and a third party workflow tool. The tool writes directly on EVENTINM1, and instead of populating the field evfields with positional data separated by "^", it writes XML text.

    The first RAD expression to be evaluated (when a new record of this type arrives) takes the XML and calls a Javascript function that parses it.

    For instance, the following XML

    <xml>
    <name>Hilton</name>
    <email>hilton@com.com</name>
    </xml>

    is parsed into two Javascript statements, which are evaluated using eval() function:

    system.vars.$xml.name="Hilton"
    system.vars.$xml.email="hilton@com.com"

    I've set some prints, and the attributions do occur without problems. But back in the RAD expressions, when I inspect the variables, both are empty :-(

    How can I make the variables created within JS available to the RAD expressions ? Checking the "Service Center Programmer's Guide", it mentions assigning variables from within the Javascript of Format Control, and it does work - but doesn't meet my needs...

    Best regards,
    Hilton

  2. #2
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    I've got the answer after some more testing - in fact, I don't need to use system.vars. Just creating the variables as

    $xml.name="Hilton"
    $xml.email="hilton@com.com"

    works fine !

    So nevermind, and sorry for bothering you all :-D

    Regards,
    Hilton

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Hello again

    I've just discovered that I had manually created the $xml variables inside SC, and that's why it was working...

    Now I had to reboot the server, and after this fresh start, the variables are not created anymore - so I'm back to the original problem: can't set variables within Javascript, and make them available to RAD expressions (event.register forms)...

    Does somebody have any ideas on how to proceed ?

    Regards,
    Hilton

  4. #4
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Initialise the variables outside javascript before calling the javascript.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  5. #5
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Default

    Quote Originally Posted by tommy View Post
    Initialise the variables outside javascript before calling the javascript.
    Hello, tommy

    I've tried your suggestion, setting the variables to "" before invoking my XML parser:

    $xml.email=""
    jscall(myFunction, evfields in $axces) // internally sets $xml.email to something read from the XML text

    But it doesn't work - after the call returns (debug messages are printed from within javascript and correctly displayed in ev.msg), the variable $xml.email is still blank :-(

    Regards,
    Hilton

  6. #6
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Try following

    Code:
    $xml.email=jscall(myFunction, evfields in $axces)
    In your function end it with

    Code:
    return what-needs-to-be-returned
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  7. #7
    Senior Member mateuszk's Avatar
    Join Date
    Nov 2006
    Posts
    302

    Default

    Quote Originally Posted by tommy View Post
    $xml.email=jscall(myFunction, evfields in $axces)
    Sorry Tommy for correcting
    Code:
    $xml.email=jscall("myLib.myFunction",evfieds in $axces)

  8. #8
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Well I just used the same notation and since Hilton says the javascript is executed (print statements) I assumed that the notation was just a simple pseudo code. But technically you are correct that is the syntax.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts