Save input on service request

How do i use a filter chain on a service request input connector in commuications builder to save the input as a xml file?

https://webapp.opentext.com/piroot/ccmprj/v210300/ccmprj-cgd/en/html/jsfilter.htm

Comments

  • Hi.

    maybe you could use a 'redirectout process' in order to save the incoming data?

    //Stig :-)

  • The problem is that if i use a redirect i get the already transformed xml from the event, i want to save the data i get before the event

  • Petrus Näslund
    edited October 7 #4

    Yes, this is possible and something we use in all projects.

    It's useful as you say to store away the original data and any filter manipulated data. Also, it can help you troubleshoot "invalid" incoming data that does not trigger any event, in those cases a redirectout process would not even be triggered.

    And of course, if you have a process based license it will also save you some transactions from not calling a redirect process :-)

    What exactly are you struggling with? The javascript itself, or how to invoke it as a filter.

    /Petrus

  • Yes the Javascript itself, if you could provide a example of the javascript it would be very helpful.

    To invoke the filter, correct me if i am wrong:
    -I should create a .js file containing the javascript
    -create a filterchain(javascript filter)
    -select the .js
    -apply the filter chain on the input connector

    /Chris

  • Yes, your invocation method looks fine.

    Here is a very simple and scaled down example of a javascript that will save the original data to a file named "bu-{randomvalue}_original.xml" and the manipulated data to a file named "bu-{randomvalue}_manipulated.xml".

    "use strict";
    var repo = require( 'repo' );

    function generateRandomString() { return Math.floor(Math.random() * Date.now()).toString(36); }

    //create a unique name for output file var uniqueName = 'bu-' + generateRandomString();

    //get the input data stream var str = repo.loadInput();

    //save the orignal data to file repo.save( uniqueName+'_orignal.xml', str );

    //do your required manipulation on str data here
    //…
    //…
    //save the manipulated data to file repo.save( uniqueName+'_manipulated.xml', str );
    //update data stream with the manipulated data repo.saveOutput( str );

    The files will by default (you can change) be saved in the root directory of the running application.

    Good luck!

    /Petrus