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

Thread: Call scripts using JavaScript

  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    3

    Default Call scripts using JavaScript

    Does anyone know how to call a normal script using JavaScript??????

    Thanks

  2. #2
    Member
    Join Date
    Feb 2002
    Location
    Phoenix, AZ
    Posts
    34

    Default

    I've not found a way to do that. What I have done however is use the script as a wrapper around the javascript. In otherwords, your script would be top-level and the JS would be called from within the JS. After that code is done, the script will finish and continue on to other panels if set up that way.

    I've wanted to call RAD apps from JS but had to use Process panels to achieve this...again calling the JS from the Process panel.

    Jeff
    Quote Originally Posted by fncosta View Post
    Does anyone know how to call a normal script using JavaScript??????

    Thanks

  3. #3
    Member
    Join Date
    Dec 2001
    Location
    United Kingdom
    Posts
    46

    Default

    This would also do it.

    //Execute script
    function Java_ScriptExecute( scriptname, record )
    {
    var rteReturnValue = new SCDatum();
    var argNames = new SCDatum();
    var argVals = new SCDatum();
    argVals.setType(8);
    argNames.setType(8);
    var argVal;

    argVal=new SCDatum();
    argVal.setType(2);
    argVal.push("name");
    argVal.push("file") ;
    argVal.push("boolean1") ;
    argNames.push(argVal);

    argVal=new SCDatum();
    argVal.setType(2);
    argVal.push(scriptname);
    argVal.push(record) ;
    argVal.push("true") ;
    argVals.push(argVal);
    // print(argVals) ;

    system.functions.rtecall("callrad",
    rteReturnValue,
    "script.execute",
    argNames,
    argVals,
    true);
    }
    Java_ScriptExecute ("name_of_script", record)

  4. #4
    Member
    Join Date
    Feb 2002
    Location
    Phoenix, AZ
    Posts
    34

    Default

    No friggin way! I've never heard of the "callrad" RTECALL. Is this new?
    Very cool by the ways...

  5. #5
    Member ResidentGenius's Avatar
    Join Date
    Nov 2007
    Location
    San Diego, CA
    Posts
    30

    Default

    callrad is one of those nifty undocumented features. I believe the last manual it showed up in was for SC3!!

    There are further examples of how it's used in JavaScript in the KMUtils ScriptLibrary record starting on line 197 in the domessageBox function.

    Keep in mind though, Support is going to be very limited for this particular rtecall. Chances are if you're using it, you're going to be on your own if something breaks.
    Former HP ServiceCenter Support Engineer

    if ( $meetings > 0 ) then ( $productivity = NULL )
    "I don't do whys." ~Dennis Markum

  6. #6
    Senior Member
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    291

    Default

    Hi,

    I've heard that they have removed some of it does not work in SM7 any longer...

    Lars

  7. #7
    Senior Member benvargas's Avatar
    Join Date
    Apr 2005
    Location
    San Diego, CA USA
    Posts
    194

    Default

    The first rule of 'callrad'... is that we do not talk about 'callrad'.


    //BEGIN EDIT

    But since we are talking about it...

    callrad

    Parameters:

    ARG(2) - Return Var

    ARG(3) - RAD application name

    ARG(4) - Array or scalar of Names (of parameters from the parameter form)

    ARG(5) - Array or scalar of Values for the names

    ARG(6) - Run this RAD app in a new thread or not

    ARG(7) - Condition for executing this RAD app


    I haven't tested in SM7 though... and as ResidentGenius mentioned, this would definitely NOT be supported by HP Support/Dev and thus really shouldn't be used within production systems.

    //END EDIT
    Last edited by benvargas; 2007-12-02 at 04:05. Reason: Added Info.

  8. #8
    Junior Member
    Join Date
    Dec 2007
    Posts
    3

    Default

    Hi
    I am trying to set an Array() object,can anyone provide a sample code for that

    Thanks
    Dinakar

  9. #9
    Senior Member tuncay's Avatar
    Join Date
    Jul 2004
    Location
    Germany
    Posts
    113

    Red face

    var a = new Array();
    a[0]= "First Element";
    a[1]="2nd Element";
    ...

    a.push("New Element at End");

    ...

  10. #10

    Default

    Why should this not be used in production systems?

  11. #11
    Senior Member glg's Avatar
    Join Date
    Aug 2004
    Location
    Chicago, IL, USA
    Posts
    714

    Default

    Quote Originally Posted by dgraham View Post
    Why should this not be used in production systems?
    If you have a problem, HP isn't going to support you.

  12. #12

    Default

    Oh, OK. That makes sense.

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

    Default

    But it is still a nice little java function which I will use and when/if HP changes callrad in future I will address it at that time.
    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.

  14. #14
    Senior Member
    Join Date
    Apr 2006
    Location
    Poland
    Posts
    680

    Default

    Quote Originally Posted by tommy View Post
    But it is still a nice little java function which I will use and when/if HP changes callrad in future I will address it at that time.
    I hope HP will not abondon this function - it is called about 4 times in script library. So they use it as well.

    My question:

    did you ever managed to have something returned in rteReturnValue ?

    system.functions.rtecall("callrad",
    rteReturnValue,
    "script.execute",
    argNames,
    argVals,
    true);
    I have twisted my brain many times and did a lot of tests - and got nothing.
    The debugger (at least in SM7) crashes when I trace the variable.

    regards
    Artur

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

    Default

    I have not experimented with it further.
    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.

  16. #16
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    Hi,
    Nice script and very useful! I try to use it from a trigger. For testing purpose I cut and paste it in a script. But I 'm experiencing trouble when using it. I use the system.record to call the function instead the record parameter. I also have an error on the third line "Script <UNKNOWN> line 3 : ERROR Unknown RAD symbol '$file' au car 1". Does anybody has a clue?
    Thanks

  17. #17
    Senior Member
    Join Date
    Apr 2006
    Location
    Poland
    Posts
    680

    Default

    I am not sure if it is possible to use it in trigger.

    Post your script - BTW.

    regards
    Artur

  18. #18
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    The script is exactly the same as above. I call it like that:

    Java_ScriptExecute("myScript",system.record);

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

    Default

    You should put all your javascripts in Scriptlibrary and call them from there like this: system.library.scriptlibrary_name.function(paramet ers)

    As Artur asked post exactly what you have in the trigger because there is no $file in the above script which your error message is about so it is not exactly like the script above.
    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.

  20. #20
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    Here is the whole javascript, It is saved in a script and launched by format control. The other script (myscript) simply displays a field from my form.

    function Java_ScriptExecute( scriptname, record )
    {
    var rteReturnValue = new SCDatum();
    var argNames = new SCDatum();
    var argVals = new SCDatum();
    argVals.setType(8);
    argNames.setType(8);
    var argVal;

    argVal=new SCDatum();
    argVal.setType(2);
    argVal.push("name");
    argVal.push("file") ;
    argVal.push("boolean1") ;
    argNames.push(argVal);

    argVal=new SCDatum();
    argVal.setType(2);
    argVal.push(scriptname);
    argVal.push(record) ;
    argVal.push("true") ;
    argVals.push(argVal);
    // print(argVals) ;

    system.functions.rtecall("callrad",
    rteReturnValue,
    "script.execute",
    argNames,
    argVals,
    true);
    }
    Java_ScriptExecute("myscript",system.record);

    The "record" in the example is it an array? Like we use it in subprogram to launch the script.execute in file parameter ($file)?
    FYI my system is SC 6.1...
    Thanks

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

    Default

    Now I am confused, you first said it was called in a trigger now you say its called from a formatctrl. Which is it? Take it from the top and list all changes you made in which elements one by one.
    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.

  22. #22
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    I have put all the function and place it in the scriptlibrary as you told me. I still get the same error. In fact I want to test it before paste it in the trigger so I use from the format control the script.execute to launch a script and from the javascript before RAD section call Java_ScriptExecute function from the script library. I didn't made any change from the Iomah's code. Could you please give me the type of each parameter because I don't think using the right.

  23. #23
    Senior Member
    Join Date
    Apr 2006
    Location
    Poland
    Posts
    680

    Default

    Try to use:
    Java_ScriptExecute("myscript",vars.$script);
    or:
    Java_ScriptExecute("myscript",vars.$L_file);
    or:
    Java_ScriptExecute("myscript",vars.$L_filed);


    As Tomy - neither I have understand what you are doing

    regards
    Artur
    Last edited by Artur; 2008-11-04 at 16:54.

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

    Default

    Quote Originally Posted by cat View Post
    I have put all the function and place it in the scriptlibrary as you told me. I still get the same error. In fact I want to test it before paste it in the trigger so I use from the format control the script.execute to launch a script and from the javascript before RAD section call Java_ScriptExecute function from the script library. I didn't made any change from the Iomah's code. Could you please give me the type of each parameter because I don't think using the right.
    Its hard to help without seeing exactly what you have done. So please again, list exactly each step you have done.

    And why do you call the javascript from a script in the first place. To test the javascript you just add the javascript call in the calculation part of the formatctrl. Then you skip the extra and unnecesary script part.
    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.

  25. #25
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    I have tried both... Still the error message. Do you think it could come from the system?

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

    Default

    Quote Originally Posted by cat View Post
    I have tried both... Still the error message. Do you think it could come from the system?
    Maybe but thats hard to tell without access to your system.....
    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.

  27. #27
    Junior Member
    Join Date
    Jun 2007
    Posts
    11

    Default

    I've found thanks Artur for the clue! The trouble came from the script called by my scriptlibrary... We are in script and all my variables are referenced by $script not by system.vars.$L_file nor system.vars.$file so it bugs. Thanks a lot!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

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