Advertisements

SIEBEL: Create a XML Structure using eScript

Created a Code to write a following Property Set  structure in XML

Problem Statment

<PropertySet>
<Contact>
<FirstName>ABC</FirstName>
<LastName>XYZ</LastName>
</Contact>
</PropertySet>

BusComp             : Contact

Vanila BS              : EAI XML Write to File

Method                               : WritePropSet

Solution

function BusComp_PreInvokeMethod (MethodName)
{
try
{
// Variable Declaration
var fName : String;
var lName : String;
var XmlContact : PropertySet;
var XmlfName : PropertySet;
var XmllName : PropertySet;
var oPS : PropertySet;
if(MethodName == "ExpConXml")
{
       //Getting a value from field
fName = this.GetFieldValue("First Name");
lName = this.GetFieldValue("Last Name");
//Start of Code to Create Single Record XML for Contact
// Initialising PropertySet
XmlContact = TheApplication().NewPropertySet();
XmlfName = TheApplication().NewPropertySet();
XmllName = TheApplication().NewPropertySet();
oPS = TheApplication().NewPropertySet();
/********Setting type for each property************
<Contact>
<FirstName>
<LastName>
***************************************************/
XmlContact.SetType("Contact");
XmlfName.SetType("FirstName");
XmllName.SetType("LastName");
/*******Creating Hierarchy Structure for xml*******
   -<PropertySet> This tag will create by default
     |- <Contact>
       |-<FirstName>
       |-<LastName> 
     |- </Contact>
   </PropertySet>
***************************************************/
XmlContact.AddChild(XmlfName);
XmlContact.AddChild(XmllName);
/*******Populating Field Value in each Property*******
 -<PropertySet>
  |- <Contact>
   |-<FirstName>Rubin</Contact>
   |-<LastName>Jason</LastName>
  |-</Contact>
 -<PropertySet>
 ***************************************************/
XmlfName.SetValue(fName);
XmllName.SetValue(lName);
// End of Code to Create Single Record XML for Contact
XmlWrite(XmlContact);                 //Calling a function to write Xml in a XML file
}
return(CancelOperation);
}
catch(e)
{
throw e;
}
finally
{
fName = null;
lName = null;
XmlContact = null;
XmlfName = null;
XmllName = null;
oPS = null;
}
return (ContinueOperation);
}
function XmlWrite(Inputs)
{
try
{
var iPS = TheApplication().NewPropertySet();
var oPS = TheApplication().NewPropertySet();
var oBS: Service;
oBS = TheApplication().GetService("EAI XML Write to File");
iPS.SetProperty("FileName","C:\\Siebel File\\Contact.xml");  // Creating a XML file name
iPS.AddChild(Inputs); // Adding a node to xml file
oBS.InvokeMethod("WritePropSet",iPS,oPS); // Invoking a method to Write Property Set
}
catch(e)
{
throw e;
}
finally
{
iPS = null;
oPS = null;
oBS = null;
}
}
Advertisements


Categories: Siebel

Tags: , , , , , , , , , , , , , , , , ,

2 replies

  1. very nice explanation. It helped me. Thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: