CallServer FormAPI – Teamsite

What is CallServer in FormAPI – Teamsite?

FormAPI is client-side technology. The user scripts that the template designer writes are loaded into the browser and executed by its JavaScript engine. There are many times, however, when code in the user script needs to access resources on a remote server.

Most commonly, the user script needs to run a database query and use the results to set the value of an item. The canonical example is the address entry form that automatically populates the city and state fields after the user has entered the ZIP code. There is no way the user script can include the entire city/state/ZIP database in the code; that information is best obtained from a server.

In Interwoven Teamsite, CallServer is method to make an HTTP request with a set of attributes-value pairs. The request may take the form of either an HTTP POST or an HTTP GET call. The target server (which can be any process that can handle an HTTP request and make a response, such as a servlet or CGI) reads the request and returns JavaScript code embedded in an HTML page. This page is loaded into a hidden frame, distinct from the frame that contains the user script and FormAPI. FormsPublisher provides a special parent.getScriptFrame() function to this hidden frame that returns the user script frame. In this way, the code returned by the server coexists with the user script and has full access to its methods and data.

The callServer() method is asynchronous. A new thread is started with the HTTP request and completes only when it finishes executing the code returned by the server. The user script code that made the request continues executing immediately after the call to callServer(). For this reason, callServer() is usually the last line of code in an event handler; the logic “picks up” in the hidden frame after the post is complete.

Here is an example illustrating a typical city/state/ZIP code form:

IWEventRegistry.addItemHandler("/zip", "onItemChange", fillCityState);


The fillCityState() handler is a function that queries a remote server for city and state:

function fillCityState(zipItem) {
	if (zipItem.isValid()) {
		var parameters = new Object(); = zipItem.getValue();
		// Make an HTTP GET to the server.
		callServer("http://myserver/getCityState", parameters, true);


The result from a call to the server (which will be given the request like http://myserver/
getCityState?zip=94086) returns code similar to this:

		<script language="javascript">
			// Get handle to the FormAPI/userscript frame.
			api = parent.getScriptFrame();
			// Set the city and state.


One of the hazards of making a remote server request is that it may take too long to return. Worse, it may not return at all. To guard against this problem, a user script can use the JavaScript setTimeOut() function to handle a request that does not return within a specified amount of time. Before it calls the server, setTimeOut() is instructed to execute an error handler function. The code that returns from the server cancels the pending error handler call (if it is running, the request succeeded). If the server does not return in time, the error handler is executed.

Adjust the user script fillCityState() function to set up the time out:

// Error handler called in 1 minute. Save ID in global variable
// for hidden frame to cancel if it succeeds.
timeout = setTimeOut("callServerFailed", 60000);

// Make an HTTP GET to the server.
callServer("http://myserver/getCityState", parameters, true);


Create a callServerFailed() function to handle the error case:

function callServerFailed() {
	alert("ZIP code lookup failed. Be sure to enter city and state.");

Finally, modify the JavaScript returned from the server to cancel the time out:

// Get handle to the FormAPI/userscript frame.
api = parent.getScriptFrame();

// Cancel the pending time out.

This does not handle the case where the server is not down, but simply slow. In this case, after one minute the user is prompted that the ZIP code lookup failed, but several moments later may suddenly see the city and state fields automatically change. To guard against this possibility, modify the callServerFailed() function to cancel the server call:

function callServerFailed() {
	alert("ZIP code lookup failed. Be sure to enter city and state.");
	// Abort the request by sending a blank page to the hidden frame.
	IWDatacapture.callServer("blank.html", new Object(), true);

This request cancels the previous request by making a new one to an empty file. This illustrates an important point about the callServer() method: only one call can be active at a time. Subsequent calls to callServer() will cancel any previous calls.

Important Note:

  1. Use only one CallServer method in Form init for setting initial values in form. To set on init Handler see below code: IWEventRegistry.addFormHandler(“onFormInit”, init);
  2. If on any event you want to set data to more than one element, do not use two call server. Use only one CallServer Method to set all the dropdown.
  3. Above shown is the first way to set the data to elements. Another way to set elements is to set data in array variable and print it on the page in script tag. See below code in perl.
    my $str = "Data1[0] = 'ABC'; Data1[1] = 'XYZ'; Data2[0] = '123'; Data2[1] = 'Test';"; 
    #you can call any subroutine here and return a string like this which sets more values
    my $data = qq{
    Content-type: text/html; charset=utf-8
    <script language="javascript">
    	var Data1 = new Array();
    	var Data2 = new Array();
    	var Data3 = new Array();
    	var api = parent.getScriptFrame();
    	api.callBackFunction(Data1, Data1, Data1);
    print $data;

Please comment here if you have any queries or suggestion. I will be posting on generalization of CallServer Method for all the template.

Inline Callout in Autonomy Interwoven Teamsite

<inline>: Provides a method for making server-side inline callout programs that return multiple XML elements to the data capture form. It is like include method in any other anguage.

Syntax of  inline callout in Teamsite:

<inline command="command name" />

Example of inline callout in Teamsite:

<inline command="command name" />

The inline callout program should return a well-formed XML document. The document’s outermost element should be a <substitution> element. It should contain any XML that is valid according to datacapture.dtd. That <substitution> element will contain six <option> elements as follow

<?xml version="1.0" encoding="UTF-8"?>
	<option value="Lead" label="Lead"/>
	<option value="Tin" label="Tin"/>
	<option value="Silicon" label="Silicon"/>
	<option value="Plastic" label="Plastic"/>
	<option value="Paper" label="Paper"/>
	<option value="Glass" label="Glass"/>

This simple callout outputs a static result. A more sophisticated callout program could query a database and return the query results as <option> elements. When a server-side inline callout program is executed, it inherits the following  environment variables:„

  • IW_DCT: The server-inclusive vpath to the datacapture.cfg in use (for example, //servername/default/main/development/WORKAREA/username/templatedata/press/events/datacapture.cfg).
  • „IW_ROLE: The role of the current data capture user (for example, editor).
  • IW_USER: The domain and full user name of the current templating user (for example, domain\username).
  • „ IW_WORKAREA: The vpath to the current workarea (for example, //servername/default/main/development/WORKAREA/username).

The exit status from a server-side inline callout should be 0 to indicate a successful execution. Normally an inline callout should not return a non-zero value. However, an example where a non-zero value may be needed to indicate an error condition is if you are populating a <select> menu by making a database query and the database is offline. Rather than displaying a form with no choices, you may prefer an exception be displayed.

Calling Perl file Using inline command:

<inline command="<path-to-iwperl Command> <path/to/perl/filename.ipl parameter1 parameter2" />

Here first we need to pass the commnad that execute the perl file code and second is the path to the perl file to be executed. Perl file should return well-formed XML as per above example. Perl file can return any number of example.

Getting passed parameter value in perl variable:

You can set first parameter value to perl variable as follow

my $var1 = $ARGV[0];

Second Parameter as

my $var2 = $ARGV[1];

Like this you can get any number of parameter passed using $ARGV.

You can get IW Home, IW Mount, Current Workarea path and DCT Path as follow:

my $iwhome = TeamSite::Config::iwgethome();
my $iwmount = TeamSite::Config::iwgetmount();
my $wapath = $ENV{IW_WORKAREA};
my $dct = $ENV{IW_DCT};

You can extract Server, Store, Branch, Workarea name, Category and Datatype in one line code as follow:

($iwserver, $store, $branch, $waname, $category, $datatype) = $dct =~ m#^\/\/([^/]+)\/([^/]+)\/(.*)\/WORKAREA\/([^/]+)\/templatedata\/([^/]+)\/([^/]+).*$#;

Please comment if this information is useful to you or any you have any queries.

What is Content Management?

Now a days, Many CMSs (Content Management Systems) are available. Many of them are in PHP, .Net, Java and other computer web languages. Every time we came accross the CMS in day life. So the question is what is content management exactly? So I write an article on it. Hope this will Help you…!

Understanding Content

Before We go into content management, We should take a moment to better understand
the concept of content itself. Only in this way we can more fully understand content management, the impact it has had in modern-day e-business, and the effectiveness, usefulness, and vital role of CMSs.

We define content in an organization as any organizational informational asset that exists in an electronic medium. Although it can be argued that any physical information resource can be classified as content, in the context of this article and content management systems we will not consider any source as content until it exists in an electronic form. Some typical examples of content include e-books, manuals, publications, web pages, video files, music, instructional material, promotional material, help text…the list goes on and on. You can classify anything as content for an organization if it fits into all of the following sections.

Content Has a Classification Type

Typically the classification type is organizational; in other words, content can be categorized by an organizational unit such as marketing content, legal content, general content, privacy content, and so forth. A company that performs only legal services may use contracts, wills, deeds of trust, billing invoices, summons, and other legal type content, while a medical publishing company may depend upon drug data sheets, patient handouts, medical books, and drug news as content

Content Has a File Type/MIME Type

Any piece of content has an associated file type, that is, the file extension that is tied to a particular program or standard. On the Windows platforms, file extensions tell the operating system the program or application to launch to service the specific file type. For example, an image file will generally have an extension such as .gif, .jpeg, .jpg, .bmp, .png, or .tif. In a CMS, file types are important to drive storage placement and delivery requirements, as well as to determine how certain files will be viewed. For example, in CMSs, the file type may control whether certain files are displayed in an iframe, a separate window, or the current window.

Content Has Metadata

Content has data attributes that describe it. These data attributes are described collectively as metadata. Metadata is used for many functions within a CMS:

Indexing data for search-related capabilities: You can intelligently add keywords to each content type via a defined taxonomy. A taxonomy is an intelligent mapping of taxons (the highest-level grouping) and taxa (subgroups under each taxon) that are unambiguous and, when taken together, consider all the possible values. For example, have you ever played the guessing game 20 Questions? This game usually starts with someone thinking of something that you then have to guess based on the responses of the 20 questions you get to ask. Usually you start by asking something similar to “Is it an animal, vegetable, or mineral?” If the other person playing with you answers your question by saying “Animal,” then you may ask “Is it a dog, cat, or human?” You will then continue until you guess the subject or you run out of questions. Each of those high-level categories of Animal, Vegetable, or Mineral would be a taxon. The taxa would then stem from the higher-level taxon; for example, the taxa for the Animal taxon might be Dog, Cat, and Bird.

Clustering on metadata and exposing that clustering to search: For example, by clustering metadata, you can list all books or all documents from the marketing department or list all the content about a certain topic. With clustering metadata, you can capture important information such as the author name or publish date. When exposed to a search engine, you then provide the ability to list all books published by a certain author or, for example, all books published from 1995 to 2001. You could also capture the subject for specific topicbased searching. By clustering with metadata, you can accomplish advanced searches such as retrieving all the books published by a certain author, of a certain subject, and published from 1995 to 2001. By having clustering data available, you can group search results and create dynamic drill-down capabilities by dynamically rebuilding the search query.

Automating system-created content using an intelligent method: You can create new and complete content dynamically, where pieces of content are combined or aggregated into an entirely new piece of content based on system requirements or at run time. If content authoring is performed where content is created at the smallest possible level, then this is possible but still difficult to accomplish. Synthesizing content is especially useful for content such as marketing collateral and presentations that should be shared across an organization or several diverse sales teams.

Determining when data should be archived and when data should be removed: These topics are often overlooked in a CMS application. By setting metadata attributes and associating those attributes with content, you can manage the demotion or deletion of content. Additionally, if your corporation has retention standards, you can programmatically control when content is archived and even where the archived content is stored.
Determining when content is promoted or published: By associating metadata with your content, you can program that content’s promotion date and time. A business content review process will control when the content has reached an acceptable publishing state, but why not also control when that content is made live?

Content Requires Storage

Simply put, content takes up space, which is typically database space or space on a file system. Some examples of storage space used to store content include network-attached storage devices such as those provided by EMC, relational databases such as Oracle or SQL Server, and file systems such as the Unix file system or NTFS. No matter what the content or the content’s type, you must have adequate space in which to store it. All content has a certain number of bits and bytes that compose it. This collection of bits and bytes takes up disk space and must be accounted for in a CMS

Content Has a Purpose Not Related to the CMS

Configuration files, templates, or any other files that are used by the CMS should not be considered actual content. Basically, any file that does not provide value to a consumer of the content is not considered content. People who use content are also known as content consumers.

Content Management Defination

Content management is the organizing, directing, controlling, manipulating, promoting, and
demoting of content and/or digital informational assets within an organization. Promoting
content means deploying content from the authoring environment to the content delivery
environment, which is usually a web server. Demoting content means removing or rolling
back content from the content delivery environment to the content authoring environment.

A CMS manages those various pieces of content described earlier. This is extremely important for organizations because as a business grows, so do the complexities of its content. Businesses have hundreds, thousands, and sometimes millions of pages of content, and with the overwhelming flood of this content, they need help! A CMS is much more than an off-theshelf piece of software that a company purchases and configures for its specific needs. To understand content management, you not only have to have a view of the proverbial forest but also need to know where each tree belongs. Implemented properly, content management and a CMS can do the following:

  • Improve delivery time from content creation to content promotion
  • Improve content quality
  • Reduce the cost of managing an organization’s global or departmental content
  • Reduce redundancies in content and reduce human error
  • Eliminate orphaned files and broken links
  • Automate content notifications and the review process
  • Enforce legal and branding standards
  • Improve content visibility and accountability throughout the delivery chain

Implemented poorly, a CMS system can be a virtual money pit, where no efficiencies are gained and many hours are wasted on a project that may provide little to no value to end users or consumers. You must understand two important facts regarding a CMS:

  1. A CMS will not improve your business process. You will have to expend some analysis cycles and rethink existing processes and procedures to enhance your business flow. Only by improving your existing process will you realize the true benefit of content management.
  2. A CMS is not free. Skipping the cost of the solution itself, you will be burning hours to implement a system. Once everyone starts to use the system and find out what the system can do, they will want more. This will also lead to additional implementations and maintenance. This is a topic we cannot reinforce strongly enough: setting up a CMS is more expensive than just building an initial website. You must be willing to accept the initial cost of building and deploying a CMS before you experience a return on investment. But you will have to trust that all of the hard work, project hours, and budget allotments will pay off in the end.

Please comment below if you have any queries. We always here to help you.