Sunday, 19 June 2011

JMS Transport

1) Downloaded ms0n.zip, ms0B.zip, me01.zip and ms0n.tar from IBM support site.


2) Extracted the zip files to the location F:\JMS\GUITool

com.ibm.mq.pcf-6.1.jar
jmsadmingui.jar
mqcontext.jar
jmsadmingui.bat

Note: The above mentioned files were created in this folder.

3) Created jndi.properties.txt in F:\JMS\JNDI

java.naming.factory.initial=com.sun.jndi.fscontext.RefFSContextFactory java.naming.provider.url=file:/ F:\JMS\JNDI

4) Set the correct path settings in jmsadmingui.bat file

Go to F:\JMS\GUITool and edit the jmsadmingui.bat file and set the
• current directory (CUR)
• MQJ
• PATH
• CLASSPATH.

Note: In the CLASSPATH specify all the jar files that were extracted from zip files and jar files located in the C:\PrograFiles\IBM\WebSphere MQ\Java\lib.

5) Modified the JMSAdmin.config file

Navigate to C:\Program Files\ibm\WebSphere MQ\Java\bin under MQSeries installation. Edit JMSAdmin.config file and perform the following modifications



• INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
• PROVIDER_URL=file:/F:\JMS\GUITool


Details to be filled by the Middleware team:


Step 1: Run (jmsadmingui.bat) Batch File

Go to F:\JMS\GUITool\ jmsadmingui.bat

Step 2: Select the JMSAdmin.config file in the GUI Tool.

C:\Program Files\IBM\WebSphere MQ\Java\bin\ JMSAdmin.config

Sept 3: Specify the file path

file:/F:\JMS\GUITool


Example Queue Creation

Example ConnectionFactory Creation

Save it and make sure .bindings files gets created under F:\JMS\GUITool

JVM Subsystem Setup


The following steps can be used to create the JVM subsystem using the Siebel WebClient


1. Start any Siebel Business Application and navigate to Site Map → Administration → Server Configuration → Enterprises.

2. In the top list applet, select the Enterprise Server that you want to configure.

3. In the middle applet, click the Profile Configuration tab.

4. Click New to create a new component profile and set the following parameters:

 Profile = JAVA
 Alias = JAVA
 Subsystem Type = JVMSubsys

5. In the Profile Parameters list applet (the bottom applet), set the following values:

a) Set the Value of the JVM Classpath parameter to contain the following:

• The location of the JNDI.properties
• The JMS provider JAR files.
• The Siebel.jar and SiebelJI_lang.jar files.

E:\seaNAM811DEV\siebsrvr\CLASSES\ SiebelJI_enu.jar
E:\seaNAM811DEV\siebsrvr\CLASSES\ Siebel.jar

b) Set the Value of the JVM DLL Name parameter to the path where you have the jvm.dll file installed. For example,

C:\Program Files\Java\j2re1.4.2_16\bin\client \jvm.dll

c) Set the Value of the JVM Options record to any JVM-specific options that you would like to enable. For example,

-Xrs -Djava.compiler=NONE

JMS Sub System Setup:

The following procedure can be used for creating the JMS Transport subsystem using the Siebel Web Client.

1. Start any Siebel Business Application and navigate to Administration → Server Configuration → Enterprises.

2. In the top list applet, select the desired Enterprise Server that you want to configure.

3. In the middle applet, click the Profile Configuration tab.

4. Click New to create a new component profile and set the following parameters:

 Profile = M3-HISD-SOFTRAX
 Alias = M3-HISD-SOFTRAX
 Subsystem Type = JMSSubsys

5. In the Profile Parameters list applet (the bottom applet), specify the following parameters

• ConnectionFactory name =com.ibm.mq.jms.MQQueueConnectionFactory
• JVM Subsystem name = JAVA
• ReceiveQueue name =
• Receive Timeout = 20000



Data Handling Sub system Setup:

To create a JMS Receiver subsystem using the Siebel Web Client a user should follow the steps below:

1. Start any Siebel Business Application and navigate to Administration → Server Configuration → Enterprises.

2. In the top list applet, select the desired Enterprise Server.

3. In the middle applet, click the Profile Configuration tab.

4. Click New to create a new component profile and set the following parameters:

 Profile = M3-HISD-SOFTRAX-DHSS
 Alias = M3-HISD-SOFTRAX-DH
 Subsystem Type = EAITransportDataHandlingSubsys

5. In the Profile Parameters list applet (the bottom applet), specify the following parameters

 Workflow Process to Execute = M3 HISD-Softrax RECV WF


Listener Component Setup:


1. Start any Siebel Business Application and navigate to Administration → Server Configuration → Enterprises.

2. In the top list applet, select the desired Enterprise Server.

 Component = M3 HISD-Softrax Integration
 Component Type = Enterprise Application Integration Receiver


3. Component Parameters Applet

 Receiver Service Name = EAI JMS Transport
 EAI JMS Transport = ReceiveDispatch
 Receiver Connection Subsystem = M3-HISD-SOFTRAX
 Receiver Data Handling Subsyst = M3-HISD-SOFTRAX-DH

Siebel Application Object Manager

Siebel Application Object Manager (AOM)

Application Object Managers (AOMs) host the Business Objects layer and Data Objects layer of the Siebel architecture.

It is a server component that creates and processes data at multiple levels.

UI layer (supported by the Siebel Web Engine)
Business object layer
Processes business logic
Data object layer (supported by Data Manager)
The AOM is used primarily to support Siebel Web client connections.

AOMs are hosted as components in the Siebel Server and run on the application server (the machine that hosts the Siebel Server). The Siebel Server provides the infrastructure for an AOM to serve multiple Siebel Web client users. Multiple AOM components can run on a single Siebel Server installation.



AOMs communicate with clients using the TCP/IP protocol through a Web server that contains the Siebel Web Server Extension plug-in (SWSE). Communication between the Web server and the AOM can be compressed and encrypted. An independent session is established to serve incoming connect requests from each client. Subsequent requests from clients are directed to the same AOM tasks until the sessions are terminated.

After startup, AOMs do not achieve their full run-time environments until after the first connect, therefore, leading to possible delays during the first connection.

Script for enrolling students for multiple courses


Account Activity List Applet:
Server Script

function WebApplet_InvokeMethod (MethodName)
{
if (MethodName == "ShowPopup")
 {
 var sIds = "";
 var sTypeAct = "";
 var sDescAct = "";
 var bc = this.BusComp();
 var isRec = bc.FirstSelected();
 while(isRec)
 {

 var sId = bc.GetFieldValue("Id");
 var sType = bc.GetFieldValue("Type");
 var sDesc = bc.GetFieldValue("Description");
 //sIds = sIds +","+ sId;
 sTypeAct = sTypeAct+","+sType;
 sDescAct = sDescAct+","+sDesc


 isRec = bc.NextSelected();
 }

 TheApplication().SetProfileAttr("SRes", sId); //sIds
 TheApplication().SetProfileAttr("Type", sTypeAct);
 TheApplication().SetProfileAttr("Desc", sDescAct);

 //TheApplication().RaiseErrorText("Hai :"+sIds);
 return (CancelOperation);
 }

            return (ContinueOperation);
}

Test Popup Applet:


Browser Script:

function Applet_PreInvokeMethod (name, inputPropSet)
{

if(name == 'PickRecord')
{
if(confirm("Do you want to Copy Student info"))
return ("ContinueOperation");
else
return ("CancelOperation");
return ("ContinueOperation");
}

}


Final:
Server Script

function WebApplet_PreInvokeMethod (MethodName)
{

    if (MethodName == "PickRecord")
    {
              var bc = this.BusComp();
             var isRec = bc.FirstSelected();
                        if(isRec)
                         {
                                      var srowId = bc.GetFieldValue("Id");
  
                        } //IF

             var sTestRes = TheApplication().GetProfileAttr("SRes");
             var sType = TheApplication().GetProfileAttr("Type");
            var sDesc = TheApplication().GetProfileAttr("Desc");
            //TheApplication().RaiseErrorText("Hai:"+sType);

            var sMsg;
            var sMsg1;
             var bo = TheApplication().GetBusObject("Account");
            var bc = bo.GetBusComp("Account");
             var bc1 = bo.GetBusComp("Action");
     
            with(bc)
                {
                         bc.ActivateField("Id");
                         bc.ClearToQuery();
                         bc.SetViewMode(3);
                         bc.SetSearchSpec("Id", srowId);
                          bc.ExecuteQuery(ForwardOnly);
                         var isRec1 = bc.FirstRecord();
            var sAccountId = bc.GetFieldValue("Id");
    if(isRec)
    {
      with(bc1)
      {
     
    var sTypeRecArray = sType.split(",");
    var sDescRecArray = sDesc.split(",");
           
            for(var i = 1; i < sTypeRecArray.length; i++)
            {
//checking        
              bc1.ActivateField("Type");
                         bc1.ClearToQuery();
                         bc1.SetViewMode(3);
                         bc1.SetSearchSpec("Type", sTypeRecArray[i]);
                          bc1.ExecuteQuery(ForwardOnly);
                         var isRec2 = bc1.FirstRecord();
               if(isRec2)
               {
               TheApplication().RaiseErrorText("Record Exist of type:"+sTypeRecArray[i]);
               }
               else
               {                            //checking
                        sMsg = sTypeRecArray[i];  
                bc1.NewRecord(NewAfter);
        // bc1.SetFieldValue("Account Id", sTestRes);
         bc1.SetFieldValue("Type", sTypeRecArray[i]);
         bc1.SetFieldValue("Description", sDescRecArray[i]);
         bc1.WriteRecord();
       }                              //checking
   }
       
        } //WITH
        }   //IF
        }  //WITH          
         

  return (CancelOperation);
 } //METHOD
// TheApplication().SetProfileAttr("SRes", sIds);
     
            return (ContinueOperation);
}

Creating an inbound WS


Objective

This document helps us to create a sample Inbound web service which uses a Business Service. An outbound Web service is created and a workflow is used to call the Inbound that we had created, thereby helping us learn how to create an Inbound and an Outbound Web Services in Siebel.

Creating an inbound

1. Create a Business Service with the following details. You can use the attached XML and import the business Service into your Siebel Tools instead.







Add the following code in the PreInvokeMethod of the Business Service.

function Service_PreInvokeMethod(MethodName,Inputs,Outputs)
{

var z;

switch(MethodName)
{

case 'Add':
z= ToNumber(Inputs.GetProperty("a") )+ToNumber( Inputs.GetProperty("b"));
Outputs.SetProperty("sum",z);
return(CancelOperation);
break;
}

return(CancelOperation);
}


2. Compile the business service to your local srf and move it to server.

3. Create an inbound web service and select the Business Service  you’ve created.



















4. Click on Generate WSDL and save the WSDL file. Here is the WSDL generated by the above eg.














Outbound Web Service

5. Open Siebel Tools (connecting to sample) and import the WSDL.

File -> New Object -> EAI -> Web service


Select the WSDL file.








This will create a proxy business service and a runtime configuration data file. Compile the BS onto the sample.



6. Import the runtime configuration data file in the outbound web services screen of the sample.

Here in this case WSDLexp.xml







7. Create a workflow in sample to call the inbound Web service thru the Proxy BS that we imported in step 5. You can also import the following workflow instead of manually creating the Workflow.



Here are the steps to create the workflow.















8. Right click and select Edit workflow process, create a workflow as shown below and create a new process property called Sum Value








9. Select the Proxy Business service Name and the method.













10. Right click the business service and click on show input arguments. Add the following details



11. Right click the Business service and click on show output arguments. Add the following details.





12. Set the debug settings in view -> options -> debug. Right click and simulate the workflow. Look at the watch window -> sum value Process property for the output.



Date Calculations in eScript

Date Arithmetic Functions in eScript

 
The AddToDate function allows you to take a date value and add or subtract days, hours, minutes, and seconds.
 
function AddToDate(sourceDate, nDays, nHours, nMinutes, nSeconds, nsign)
{
  // Parameters : 
  // sourceDate  :  Date object
  // nDays, nHours , nMinutes , nSeconds  :  Integer numbers
  // nsign : Can have two values : 1 or -1
  //             1 indicates to ADD to the sourceDate
  //            -1 indicates to SUBTRACT from the sourceDate
  // Returns : A date object, after adding/subtracting
  // ndays,hNours,nMinutes
  //          and nseconds to the sourceDate.
  var retDate = sourceDate;
  retDate.setDate(retDate.getDate()+nsign*nDays);
  retDate.setHours(retDate.getHours()+nsign*nHours);
  retDate.setMinutes(retDate.getMinutes()+nsign*nMinutes);
  retDate.setSeconds(retDate.getSeconds()+nsign*nSeconds);
  return (retDate)  
}

 
The DiffDays function calculates the number of days between two date values.
 
function DiffDays(date1, date2)
{
  // Parameters : 
  // date1  :  Date object
  // date2  :  Date object
  // Returns :  Number of days between date1 and date2
  return ((date2.getTime()-date1.getTime())/(1000*60*60*24));
}

 
The DateToString function reformats a date value as a string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss".
 
function DateToString(dDate)
{
  // Parameters : 
  // dDate  :  Date object
  // Returns : A string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss"
 
  var sMonth = ToString(dDate.getMonth() + 1);
  if (sMonth.length == 1) {sMonth = "0" + sMonth;}
  var sDay = ToString(dDate.getDate());
  if (sDay.length == 1) {sDay = "0" + sDay;}
  var sHours = ToString(dDate.getHours());
  if (sHours.length == 1) {sHours = "0" + sHours;}
  var sMinutes = ToString(dDate.getMinutes());
  if (sMinutes.length == 1) {sMinutes = "0" + sMinutes;}
  var sSeconds = ToString(dDate.getSeconds());
  if (sSeconds.length == 1) {sSeconds = "0" + sSeconds;}
  if (sHours == "00" && sMinutes == "00" && sSeconds == "00")
    return (sMonth +"/"+  sDay +"/" + dDate.getFullYear())
  else
    return (sMonth +"/"+  sDay +"/" + dDate.getFullYear() +" "+sHours+":"+sMinutes+":"+sSeconds);
}

 
The StringToDate function takes a date value which is formatted as a string and returns a date object.
 
function StringToDate(sDate)
{
  // Parameters : 
  // sDate  :  A string with the format "mm/dd/yyyy" or "mm/dd/yyyy hh:mm:ss"
  // Returns : a Date object
 
  var ArDateTime = sDate.split (" ");
  var  ArDate = ArDateTime[0];
  var  splitDate = ArDate.split ("/");
  var nDay = ToNumber(splitDate[1]);
  var nMonth = ToNumber(splitDate[0]);
  var nYear = ToNumber(splitDate[2]);
  if (ArDateTime.length == 1)
     return (new Date(nYear, nMonth-1 , nDay))
  else
  {  var ArTime = ArDateTime[1];
      var splitTime = ArTime.split(":");
      if (splitTime[0]=="00" && splitTime[1]=="00" && splitTime[2]=="00" ) 
            return (new Date(nYear, nMonth-1 , nDay))
      else
      {
            var nHours     = ToNumber(splitTime[0]);
            var nMinutes   = ToNumber(splitTime[1]);
            var nSeconds = ToNumber(splitTime[2]);
            return (new Date(nYear,nMonth-1,nDay, nHours, nMinutes, nSeconds)) 
      }
   }
}

Open contacts for a particular account in new page on click on a button and sending email for a selected contact in SFDC

  Visual force code




<apex:page controller="test_Controller" >
<apex:form >
<script language="javascript">
function hello()
{
alert('Hello here ');
}
</script>
<apex:commandButton value="Send Email" action="{!SendEmail}"/>
<apex:pageBlock title="Account Records">
<apex:pageBlockTable value="{!liRecords}" var="li">
<apex:column >
<input type="checkbox" value="{!li.check}" onchecked="{!send}"/>

</apex:column>
<apex:column value="{!li.opr.OpportunityId}" />
<apex:column value="{!li.opr.Role}" />
<apex:column value="{!li.opr.ContactId}" />

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>







controllerpublic class test_Controller
{
public String send {

get;
set
{

sendcontacts.add(ApexPages.currentPage().getParameters().get('li.contactid'));
}

}


public List <String> sendcontacts;
public PageReference SendEmail()
{
for(Record r : liRecords)
{
if(r.check==true)
{
Contact c = [Select Id, Name, Email FROM Contact where id=:r.opr.contactId];
if(c!=null)
{
if(c.email!=null)
{
Messaging.reserveSingleEmailCapacity(2);

// Processes and actions involved in the Apex transaction occur next,

// which conclude with sending a single email.


// Now create a new single email message object

// that will send out a single email to the addresses in the To, CC & BCC list.

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// Strings to hold the email addresses to which you are sending the email.

String[] toAddresses = new String[] {c.email};
String[] ccAddresses = new String[] {'smith@gmail.com'};


// Assign the addresses for the To and CC lists to the mail object.

mail.setToAddresses(toAddresses);
mail.setCcAddresses(ccAddresses);

// Specify the address used when the recipients reply to the email.

mail.setReplyTo('support@acme.com');

// Specify the name used as the display name.

mail.setSenderDisplayName('Salesforce Support');

// Specify the subject line for your email address.

mail.setSubject('New Case Created : ' + case.Id);

// Set to True if you want to BCC yourself on the email.

mail.setBccSender(false);

// Optionally append the salesforce.com email signature to the email.

// The email address of the user executing the Apex Code will be used.

mail.setUseSignature(false);

// Specify the text content of the email.

mail.setPlainTextBody('Your Case: ' + case.Id +' has been created');

mail.setHtmlBody('Your case:<b> ' + case.Id +' </b>has been created<p>'+
' View case <a href=https://na1.salesforce.com/'+case.Id+'>click here</a>');

// Send the email you have created.

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

}

}


contactid=ApexPages.currentPage().getParameters().get('li.contactid');
contacts=[Select Id, Name, Email FROM Contact where name=:contactid];

return null;
}

public List<OpportunityContactRole> oppList;
public String Oppid {get;set;}
public string contactid;
public List <Contact> contacts;
public List<record> liRecords ;


public List<record> getliRecords()
{
return lirecords;
}

public List<OpportunityContactRole> getoppList()
{
return oppList;
}

public test_Controller()
{
liRecords = new List<record>();
oppList = new list<OpportunityContactRole>();
oppid = ApexPages.currentPage().getParameters().get('id');
System.debug('=======================>>Oppid'+oppid);
oppList = [Select Id, OpportunityId, ContactId, Role FROM OpportunityContactRole where OpportunityId=:oppid];
for(OpportunityContactRole t : opplist)
{
record r = new record();
r.check = false;
r.opr = t;
liRecords.add(r);
}
System.debug('=======================>>Oppid'+oppList );
System.debug('=======================>>Rcords'+lirecords );

}

class record
{
public Boolean check{get;set;}
public OpportunityContactRole opr{get;set;}
}



}