SiebelUnleashed Forum is up and running.. Check out the new forum. | Next Tip »Home

Providing Value in script

OkAvarageGoodVery GoodExcellent (3 votes, average: 4.00 out of 5)
Loading ... Loading ...

Till few days ago I was never able to use EAI File Transport business service “Send” method in eScript. Every time I used it, I would get a blank document but the same thing worked without a problem in workflow.

“Send” method has two main input arguments

  1. FileName: which is actually a path where you want to create file
  2. <Value>: The data that you want to write in file

Here is the eScript code I tried:


   var inpArg = TheApplication().NewPropertySet();
   var outArg = TheApplication().NewPropertySet();
   var svcObj = TheApplication().GetService(“EAI File Transport”);
   var testString = “Test string that should be written in file”;
   inpArg.SetProperty(“FileName”, “C:\temp.txt”);
   inpArg.SetProperty(“<Value>”, testString);
   svbObj.InvokeMethod(“Send”,inpArg,outArg);

This above code would create an empty file. I just couldn’t understand that if I provide exactly these two input arguments in a workflow that it worked without any problem.

I was able to find the reason and solution while trying to use XML Converter BS “XMLToPropSet” method which has similar input argument “<Value>” .

When I tried same approach to convert an XML string to property set I got an error that input is empty, which mean that it is not able to get value in <Value> input argument that we are supplying.

So, After searching Metalink I was able to find the below given code to make it work:

   var inpArg = TheApplication().NewPropertySet();
   var outArg = TheApplication().NewPropertySet();
   var svcObj = TheApplication().GetService(“EAI File Transport”);
  var testString = “Test string that should be written in file”;
   inpArg.SetProperty(“FileName”, “C:\temp.txt”);
   inpArg.SetValue(testString);
   svbObj.InvokeMethod(“Send”,inpArg,outArg);

The only thing that has changed in the above code is using SetValue instead of SetProperty to pass the value. So, you should use SetValue instead of SetProperty to set the input argument of all the Business Services that expect a <Value> input argument.

I hope this will save somebody from hours of debugging.

Related Posts


Article by neel

Authors bio is coming up shortly. neel tagged this post with: Read 416 articles by neel
View Comments Post a Comment
  1. Amol Tandon says:

    While trying script was giving me some error. So if you want to try it out use this script

    var inpArg = TheApplication().NewPropertySet();
    var outArg = TheApplication().NewPropertySet();

    var svcObj = TheApplication().GetService(“EAI File Transport”);
    var testString = “Test string that should be written in file”;
    inpArg.SetProperty(“FileName”, “C:\\temp.txt”);
    inpArg.SetValue(testString);
    svcObj.InvokeMethod(“Send”,inpArg,outArg);
    Outputs.AddChild(inpArg);

  2. Gaurav Gupta says:

    Good Post Neel !!!

    These thing we really need to take care while using various vanilla Business Services in scripting. The different methods we generally you use on propertyset are SetType(), SetProperty(), SetValue(), AddChild().

    Here is how you can find which one to use :

    Tools -> Business Service -> Business Service Method -> Business Service Method Arg.

    Scroll right to see the value in “Storage Type” column. If Storage Type = Value, then you need to use GetValue()/SetValue(), if “Property”, you need to use GetProperty()/SetProperty() and so on.

    This is the reason we never need to specify any SetValue/SetProperty while using these Business Services in Workflows. Using “Storage Type” value, Workflows creates the complete PropertySet on its own.

    Cheers !!!!

  3. Manju says:

    Thanks brother, same problem was with me, fortunately i found this

  4. fang says:

    >I hope this will save somebody from hours of debugging.

    You definitely did. Thanks!

  5. Bejoy says:

    Dont all Transport BS use the Value of a Input PropertySet as a message. For e.g. when calling EAI MQSeries Transport etc we need to pass the xml in the Value.

blog comments powered by Disqus

Polls

Do you know how to use replace function?

View Results

Loading ... Loading ...