Script functions reference > Preview functions > Preview examples

Preview examples
Example 45
A Message is configured with two Processes and four output connectors. At runtime, the output connector and Process are selected depending on the type of preview job. If the preview is invoked from a web service, the content type is also considered.
Processes:
In the Runtime Process settings, the Processes are set up to be triggered using the CallProc scripting function (that is, the Select automatically option is cleared).
Output connectors:
The Message is configured to be invoked through service requests. If the preview is invoked from a web service, the expected content type (if any) from the web service request is also considered when selecting the connector for the preview Process.
The following script is run as a Before Message script.
$selectedConnector = "PDF";
$selectedProcess = "MyPageOUT";

if(IsPreview())
{
preproclog(0, "In preview, checking type and requested
connector");

if(GetPreviewType() = 1)
{
preproclog(0, "Web service preview");
          $requestedCT = GetRequestedPreviewContentType();
          
if($requestedCT = "application/pdf")
$selectedConnector = "PDF";

else if($requestedCT = "application/jpg" || $requestedCT
= "application/jpeg")
$selectedConnector = "JPG";

else if($requestedCT = "application/xml" || $requestedCT
= "text/xml")
{
$selectedConnector = "XML";
$selectedProcess = "MyXMLOUT";
}
}
else if(GetPreviewType() = 2)
{
$selectedConnector = "HTTP response";
}
else
{
preproclog(0, "Other preview");
}
}

preproclog(0, "Process: " + $selectedProcess);
preproclog(0, "Connector: " + $selectedConnector);

CallProc($selectedProcess);
 
 
 
OpenText StreamServe 5.6 Updated: 2013-03-01