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

Thread: Filling fields forms in a link

  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    11

    Default Filling fields forms in a link

    Hi all,

    I have created a script library that calls the CMDB webservice in order to retrieve the data of a CI.

    What I want to do and I have no idea how to do it is make a call to that script from the probsummary link and fill the fields in that form with the data retrieved from my JS function created.

    Anybody can help me please?

    Thanks a lot in advance.

    Regards,
    Jose Carlos Perez

  2. #2
    Junior Member
    Join Date
    Nov 2008
    Posts
    5

    Talking

    hi,

    because I have no idea about your requirement. so I just say what I have done befor, maybe it can help you.

    about 1 years ago, I have to make a function in problem management module. that's operator click a button, and this button will get some field value from current form. and use the value(maybe it's passport number etc.) to access a external web service which provide by customer. and customer already give me the wsdl url about this webservice. actualy, I will get some picture binary data(passport photo of this passport holder) from this webservice and show this picture in client PC's default internet browser.

    I did it follow step:

    1. create new button definition in Display Options.
    2. use the wsdl2js tools in Service manager, to generate the base communation js library, according the wsdl url which provide by customer.
    3. code some javascript, try to use the base library which generate in step 2, include invoke the webservice function, pass parameter to webservice, and get the reponse data from webservice, decode it and wrote it to a local picture file etc.
    4. test the javascript in script library tools
    5. add the javascript code in pre-javascript tab page in the user-defined button in Display options

    6. test it.

  3. #3
    Junior Member
    Join Date
    Nov 2008
    Posts
    11

    Default

    Hi,

    I have made steps 1 to 4 with success. The difference between my requirement and yours is that the webservice I am calling return a list of fields (CI information) and I want to call this script from the New Incident form and fill the detailed data of a specific CI into the form fields (that data is in the object returned by the JS function).

    So, I have generated a function to store the info retrieved from the ws as the following one:

    function GetCIOutput()
    {
    this.$$attributes = new Array();
    this.$$xmlNames = new Array();
    this.$$objNames = new Array();
    this.getName = getName;
    this.getXmlName = getXmlName;
    this.setContent = setContent;
    this.addContent = addContent;
    this.getContent = getContent;
    this.isFault = isFault;
    this.$$elementChildren = new Array();
    this.$$name = "CIOutput";
    this.$$xmlNames[ "CIOutput" ] = "CIOutput";
    this.instanceId = new xsd_string();
    this.$$elementChildren.push( "instanceId" );
    this.nombre = new xsd_string();
    this.$$elementChildren.push( "name" );
    this.contrato = new xsd_string();
    this.$$elementChildren.push( "contract" );
    this.location = new xsd_string();
    this.$$elementChildren.push( "location" );
    }

    And I have JS function that return that object.
    What I need to know is:

    - How to call to the JS function from the link probsummary. I guess it should be with the following line but I want to confirm that:
    jscall("script_library_name.function", arguments);

    - Where should I include exactly the previous call
    - Once I have called the function, how to manage the returned object to parse it and fill the necessary fields in the New Incident screen.

    I hope that clarify a bit more my objectives.

    Thanks a lot for the help.

    Regards,
    Jose Carlos Perez

  4. #4
    Junior Member
    Join Date
    Nov 2008
    Posts
    5

    Default

    why you try trigger this javascript in a link process? because in my requirement, I trigger it in a button in the view. when operator click this button, will trigger the javascript to connect the web service and get what we need. and anylst it fill into the $File.

    js code like this:
    (in the pre js page of the display option in one view)

    -------------------------------------------------

    var hello_service = new system.library.HelloService.HelloService();
    var hello_request = new system.library.HelloService.helloRequest();
    hello_request.name.setValue("");
    var hello_response = hello_service.invoke(hello_request);

    if(!hello_response.isFault())
    {
    var t = hello_response.helloReturn.getValue();
    print("[info] response msg length from webservice:" + system.functions.lng( t ));
    var decode = base64Decode( t );
    var filePath = "C:\\Tomcat5.5\\webapps\\ROOT\\a.jpg";
    var isBinary = "b";
    var opnum = writeFile( filePath, isBinary, decode );
    }
    else
    {
    print(hello_response.faultstring.getValue());
    }


    system.vars.$resp = "http://localhost/a.jpg";

    -------------------------------------------------

    let's image it, now situation is that you will create a incident in your form, and fill something in the new incident form, and to some special form field, you need got the value list from a webservice? use this value list to dynamic generate the drop down list for operator?

    if you are sure about that you want trigger js in the link process, maybe you can try the use the javascript in "javascript" tab page of one line line in "probsummary" link

    actually jscall is a RAD function which should be used in some RAD expression to call javascript function. your use method is correct.


  5. #5
    Senior Member pfilaretov's Avatar
    Join Date
    Jan 2009
    Location
    St.-Petersburg, Russia
    Posts
    112

    Default

    Quote Originally Posted by wxsoft View Post
    hi,
    about 1 years ago, I have to make a function in problem management module. that's operator click a button, and this button will get some field value from current form.
    Did you do this ("get some field value from current form") using js in pre-rad tab of Display Option?
    If so can you post the script to do this, please!
    if not, how did you do this? I have the same task.

    Thanks a lot in advance.

+ 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