Terrasoft CRM 3.0 SDK > Examples > Files > IServiceInfoExampe.js
ContentsIndex
IServiceInfoExampe.js

 

Description

 

Body Source
//-----------------------------------------------------------------------------
// IServiceInfoExample.js file
//-----------------------------------------------------------------------------
// There is described the usage of the IServiceInfo object in the example. 
//-----------------------------------------------------------------------------
//@ Start Example

// Message displaying function 
function ShowMessage(Str) {
    for (var i = 1; i < arguments.length; i++ ) {
        Str = Str.replace(new RegExp('%' + i), arguments[i]);
    }
    WScript.Echo(Str);
}

// Function of the service information formation
function GetServiceInfo(ServiceInfo, Value) {

	// A variable for the data strings formation 
	var TotalString = new String();
	
	// Result value initial cleaning 
	Value.Value.Clear();	
	
	// Sequential adding of the service's information to the storage
	TotalString = "Caption: " + ServiceInfo.Caption; 
	Value.Value.Add(TotalString);

	TotalString = "Identifier of the user who created the service: " + 
	    ServiceInfo.CreatedByID; 
	Value.Value.Add(TotalString);
	
	TotalString = "Created on: " + ServiceInfo.CreatedOn; 
	Value.Value.Add(TotalString);

	TotalString = "Database identifier: " + ServiceInfo.DatabaseID; 
	Value.Value.Add(TotalString);

	TotalString = "Description: " + ServiceInfo.Description; 
	Value.Value.Add(TotalString);

	TotalString = "Service identifier: " + ServiceInfo.ID; 
	Value.Value.Add(TotalString);

	TotalString = "Identifier of the user who locked the service: " + 
	    ServiceInfo.LockedByUserID; 
	Value.Value.Add(TotalString);

	TotalString = "Identifier of the user who changed the service: " + 
	    ServiceInfo.ModifiedByID; 
	Value.Value.Add(TotalString);

	TotalString = "Modified on: " + ServiceInfo.ModifiedByOn; 
	Value.Value.Add(TotalString);

	TotalString = "Service type code: " + ServiceInfo.ServiceTypeCode; 
	Value.Value.Add(TotalString);

	TotalString = "USI: " + ServiceInfo.USI; 
	Value.Value.Add(TotalString);

	TotalString = "Version: " + ServiceInfo.Version; 
	Value.Value.Add(TotalString); 
}

// Creating the database connection and data storage objects
var Connector = new ActiveXObject('TSDskObjectLibrary.DskConnector');
var Value = new ActiveXObject('TSObjectLibrary.Value');
Value.Value = new ActiveXObject('TSObjectLibrary.StringsList');

if (Connector.Login("Example of the IServiceInfo use")) {

	// Reading the information about the service 
	// The following parameters can be transferred to the function InformationsByUSI : 
	// not full USI, but code only
	var ServiceInfo = Connector.Services.InformationsByUSI('scr_Account');

	// Formation and displaying the information about the 'scr_Account' service
	GetServiceInfo(ServiceInfo, Value);
	ShowMessage(Value.Value.Text);  

	// Reading the information about the service based on the full USI
	var USI = 'X15\\Workspaces\\Accounts\\General\\Main Grid\\tbl_Account';
	ServiceInfo = Connector.Services.InformationsByUSI(USI);

	// Formation and displaying the information about the 'tbl_Account' service
	GetServiceInfo(ServiceInfo, Value);
	ShowMessage(Value.Value.Text);  
		
	// Formation and displaying the information about the first found five services in the collection
	for (i = 0; i<5; i++) {
		ServiceInfo  = Connector.Services.Informations(i);
		GetServiceInfo(ServiceInfo, Value);
		WScript.Echo(Value.Value.Text);
	}
	
}
//@ End Example

Copyright (с) Terrasoft 2002-2007.