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

Thread: Execute javascript from javascript ?

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

    Default Execute javascript from javascript ?

    Sounds easy enough to do. Put it into a function and call it.

    However suppose you have the javascript in a datarecord and want to excute it from a javascript without it being a function in a scriptlibrary.

    Is that possible like it is to execute rad code with parse() and eval() ?
    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.

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

    Default

    Code:
    js("print(\"bla bla bla\")")
    As long as you remember about escaping double quotes
    you're free to do almost everything.
    After all, this is how they execute js on RAD panels :-)

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

    Default

    I will try that.
    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.

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

    Default

    In case this doesn't work for you,
    don't forget there's a JS native eval()

  5. #5
    Senior Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    eval is the way to go. See for a similar setup the "context" stuff in IIA (ScriptLibrary "context"). Info from a regualr record (contextAction) is evaluated in the function.

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

    Default

    Quote Originally Posted by harn145 View Post
    eval is the way to go. See for a similar setup the "context" stuff in IIA (ScriptLibrary "context"). Info from a regualr record (contextAction) is evaluated in the function.
    Can you post the example. I do not have IIA at present.
    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
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    Sure:

    Code:
    function RunAction(fFile, ContextActionName)
    {
    	var fContextAction = new SCFile("contextAction");
    	var sql = "name=\""+ContextActionName+"\"";
    	
    	rc = fContextAction.doSelect( sql );
    	
    	if (rc == RC_SUCCESS)
    	{
    		var code = fContextAction.code;
    		eval(code);
    		
    		if (rc == RC_SUCCESS)
    		{
    			return fRecords;
    		}
    	
    		else
    			return false;
    	}
    }
    An example of contextAction code:
    Code:
    var fRecords = new SCFile("probsummary");
    var sql = "problem.status~=\"Closed\" and logical.name=\""+fFile.logical_name+"\"";
    rc = fRecords.doSelect( sql );

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

    Default

    Thanks. Thats exactly what I need.
    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)

     

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