Get a Field Value Through Browser Scripting in Siebel

8/16/2012 No Comment

Get a Siebel Field Value Through Browser Script.

How Can You Get a Field Value for Fields Not Exposed in the Active Applet.

Solution

In browser script, only the values of the fields currently exposed on the active view can be retrieved using the BusComp.GetFieldValue method. The following rules apply:

If a field is exposed only in the More section of the applet, it is available through browser script only when the applet is expanded.

Although the system field Id can always be retrieved from a browser script, other system fields which are available through server script are not by default available through browser script. The Force Active and Link Specification field properties do not make a field value available through browser script.

These restrictions are in place to reduce the amount of data that must be passed from the server to the browser, thereby improving performance. In order to retrieve through browser script the value of fields not exposed on the active view, you can either expose the fields as hidden fields on the applet, or you can execute a business service on the server to retrieve the field value. Document 477229.1 provides details on how to set up hidden fields for this purpose. This document provides the business service solution.

Solution

Please note that this code is provided as an example only. It should be modified as needed for your business requirements and to add error handling, and tested carefully in your test environment prior to any production implementation. For general scripting best practices, please refer to Document 477766.1.

In Siebel Tools, create a new business service called MyGetFieldValue. To this business service:
  • Add a new Method GetField with the following method arguments: 
Name
Type
fieldname
Input 
Id
Input
boName
Input
bcName
Input
fieldvalue
Output
  • Add server script using eScript or Siebel VB that instantiates the business component out of the UI context so that you can activate the field using ActivateField method. The sample code shown below is written in eScript. 
function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{ if (MethodName == "GetField")
{ var sfield = Inputs.GetProperty("fieldname");
var sId = Inputs.GetProperty("Id");
var boName = Inputs.GetProperty("boName");
var bcName = Inputs.GetProperty("bcName");
var bo = TheApplication().GetBusObject(boName);
var bc = bo.GetBusComp(bcName);
bc.ClearToQuery();
bc.SetViewMode(AllView);
bc.ActivateField(sfield);
bc.SetSearchSpec("Id", sId);
bc.ExecuteQuery();
 if (bc.FirstRecord())
{
var svalue = bc.GetFieldValue(sfield);
Outputs.SetProperty("fieldvalue",svalue);
}
else Outputs.SetProperty("fieldvalue","");
 return (CancelOperation);
 }
return (ContinueOperation);}
function Service_PreCanInvokeMethod (MethodName, &CanInvoke)
{ if (MethodName == "GetField")
{ CanInvoke = "TRUE";
 return (CancelOperation);
 }
 return (ContinueOperation);
}
Call the business service from browser script to retrieve the name of a field not being displayed on the active applet. This sample code assumes the browser script is on an applet: 
var inp = theApplication().NewPropertySet();
var outs = theApplication().NewPropertySet();
inp.SetProperty("Id", this.BusComp().GetFieldValue("Id"));
inp.SetProperty("fieldname","City State");
inp.SetProperty("boName",this.BusObject().Name());
inp.SetProperty("bcName",this.BusComp().Name());
outs = serv.InvokeMethod("GetField",inp);
svalue = outs.GetProperty("fieldvalue");
alert(svalue);
var serv = theApplication().GetService("MyGetFieldValue");
The business service has to be registered to be used by the application.
For Siebel 7.x, remember to declare the Business Service in the application .cfg file using the ClientBusinessServiceX parameter in the SWE section, for example:

[SWE]
ClientBusinessService0 = "MyGetFieldValue"

For more information, refer to Siebel Bookshelf version 7.8 > Siebel Object Interfaces Reference > Interfaces Reference > Application Methods > GetService Method

For Siebel 8.x, please do the following:
  • Log into Siebel Tools and locate the application name you are using (e.g :“Siebel Universal Agent”) researching on Application object type from the Object Explorer. 
  • Expand the Application object to expose the “Application User Prop” objects. 
  • Create a new record for each business service to be declared, setting the Name and Value properties as such for each: 
e.g.:
Name = ClientBusinessService0
Value = XML Converter

This information is also mentioned at Document 477064.1. For more information, refer Siebel Bookshelf version 8.0> Siebel Object Interfaces Reference > Interfaces Reference > Application Methods > GetService Method

Compile a new .srf file and test the functionality to ensure it meets your business requirements.

No comments :

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer