Tuesday, October 18, 2011

Scripts


1. /*total revenue of all opportunity records*/

function BusComp_PreWriteRecord ()
{
var bo = TheApplication().ActiveBusObject();
var ConBC = bo.GetBusComp("Contact");
var OptyBC = bo.GetBusComp("Opportunity");
var ConId = GetFieldValue("Id");

ConBC.ActivateField("Total Revenue");
OptyBC.ClearToQuery();
OptyBC.SetViewMode(3);
OptyBC.SetSearchSpec("Key Contact Id",ConId);
OptyBC.ExecuteQuery();
var z = OptyBC.FirstRecord();
var tot = 0;
while(z != 0)
{
tot = tot + ToInteger(OptyBC.GetFieldValue("Primary Revenue Amount"));
z = OptyBC.NextRecord();
}

ConBC.SetFieldValue("Total Revenue",tot);

//TheApplication().RaiseErrorText("Revenue Total is:" +tot);

return (ContinueOperation);
}






Account Team Mvg Applet


Mvl: Opportunity


The business component 'Contact' does not have a multi-value field for MVLink 'Opportunity' which corresponds to field 'Opportunity.Revenue Currency Code'. This field is required.(SBL-DAT-00454


Primary Revenue Amount
Primary Revenue Close Date
Primary Opportunity Id






Var bo = TheApplication().ActiveBusObject();
Var view = bo.ActiveViewName();
TheApplication().SWEAlert(“You are in the view”, +view);



If (TheApplication.ActiveViewName<>"") then

MsgBox"....."

End If









Returns the name of the applet that has input focus.
var applet;
applet = TheApplication().ActiveApplet();
Returns the business component associated with the active applet.
var busComp;
busComp = theApplication().ActiveBusComp()
Returns the business object for the business component of the active applet.
var busObject;
busObject = theApplication().ActiveBusObject();
Returns the name of the active view.
var viewName;
viewName = theApplication().ActiveViewName();







var bo = TheApplication().ActiveBusObject();
var bc = TheApplication().ActiveBusComp();



if(TheApplication().ActiveViewName == "Contact Detail View")
            TheApplication().Alert("you are in Contact Activities View")
              return (ContinueOperation);





2.  /* Call Center Agent 1 cannot create a new record in Account List Applet*/


function WebApplet_PreCanInvokeMethod (MethodName, &CanInvoke)
{
if(MethodName == "NewRecord")
{   var emppos = TheApplication().PositionId();
    
        if(emppos == "1-36T")
           {
              CanInvoke = "False";
              return(CancelOperation);
            }
    
  CanInvoke="True";
      

}
return (ContinueOperation);
}

Priority
Priority
Activity SR Id-fkf


3. /* if SR status is 1-asap all its activities status also shld be 1-asap*/


function BusComp_WriteRecord ()
{

var Prt = this.GetFieldValue("Priority");
if(Prt = "1-ASAP")
 {
   var bosrvreq = TheApplication().GetBusObject("Service Request");
   var bcaction = bosrvreq.GetBusComp("Action");
   var SRId = this.GetFieldValue("Id");
   var z;

    with (bcaction)
  {
    ClearToQuery();
    ActivateField("Activity SR Id");
    ActivateField("Priority");
    SetViewMode(AllView);
    SetSearchSpec("Activity SR Id",SRId);
    ExecuteQuery(ForwardBackward);
    z = FirstRecord();
   }

 
   while(z!=0)
   {
    
     bcaction.SetFieldValue("Priority", "1-ASAP");
     bcaction.WriteRecord();
     z = bcaction.NextRecord();
      
   }
 return(CancelOperation);
 }


}

4. /*service engg  can not close the service request unless and until all the activities under that service request has status “Done”*/


function BusComp_PreSetFieldValue (FieldName, FieldValue)
{

   if(FieldName == "Status")
   {
      if(FieldValue == "Closed")
        {
          var bosrvreq = TheApplication().ActiveBusObject();
          var bcsrvreq = bosrvreq.GetBusComp("Service Request");
          var bcaction = bosrvreq.GetBusComp("Action");
          var srid = this.GetFieldValue("Id");
         
          with(bcaction)
          {
            ActivateField("Status");
            ActivateField("Activity SR Id");
            SetViewMode(3);
            ClearToQuery();
            SetSearchSpec("Activity SR Id", srid);
            ExecuteQuery();
           
           }
          
           var firstrec = bcaction.FirstRecord();
          
           while(firstrec != 0)
             {
                 if(bcaction.GetFieldValue("Status") == "Done")
                    {
                       firstrec = bcaction.NextRecord();
                    } 
                  else
                    {
                    TheApplication().RaiseErrorText("You cannot close this SR untill all the activities are DONE");
                    return(CancelOperation); 
                    }
              }     
           }       
    }
            return (ContinueOperation);
}



Constrain By
Each pick map object definition has a child object definition of type Pick Map UpdOnlyIfNull. If you
add one of these child object definitions to whichever pick map constrains the picklist, then Siebel
applications ignore the constraint if the constraining value is NULL. You might still have a non-NULL
picklist field that still returns no records, but this prevents you from seeing no records when the
picklist field is NULL.





Frequently Asked Questions (FAQs)

FAQ 2134: How Does the Pick Map UpdOnlyIfNull Object Definition Work with Copy and Constrain Pick Maps?


--------------------------------------------------------------------------------
Last Modified: 20 August 2004
Area(s): Configuration - General 
Release(s): V5 (Siebel 99-Enterprise), V6 (Siebel 2000-Enterprise), V7 (Enterprise), V5 (Siebel 99-MidMarket), V6 (Siebel 2000-MidMarket), V7 (MidMarket), V7 (Professional)
Database(s): All Supported Databases
App Server OS(s): All Supported Platforms
Latest release tested against: V7 (Enterprise)
Keywords: pick map, UpdOnlyIfNull, copy, constrain, filter, pick list, picklist, pick applet, dynamic picklist

--------------------------------------------------------------------------------



The Pick Map UpdOnlyIfNull object is used to disable a copy pick map or disable a constrain pick map depending on a null or non-null value of a specified field. For background on copy pick maps and constrain pick maps, refer to Siebel Bookshelf version 7.7 > Object Types Reference > Siebel Object Types > Pick Map.

If a Pick Map UpdOnlyIfNull is defined as a child of a copy pick map, the copy operation will only be executed if the Pick Map UpdOnlyIfNull field value is null. If the Pick Map UpdOnlyIfNull field value is non-null, the field defined in the pick map will not be reset.

If the Pick Map UpdOnlyIfNull is defined as a child of a constrain pick map, the constrain will only be executed if the Pick Map UpdOnlyIfNull field value is non-null. If the UpdOnlyIfNull field is null, the constraint will be not applied, therefore all available values will appear in the pick list for the field specified in the pick map.

The following examples illustrate how the Pick Map UpdOnlyIfNull object can be used with copy and constrain pick maps. Although some of the fields used in the examples below only pertain to Siebel 7, the same principles may be applied to earlier Siebel application releases.

Example 1: Using Pick Map UpdOnlyIfNull in a Copy Pick Map

In this example, a copy pick map is defined for the Contact Last Name field on the Service Request buscomp in order to copy the primary account associated with the contact to the Account field on the service request record. A Pick Map UpdOnlyIfNull is defined so that if the account on the service request is already set, it will not be reset when the contact on the service request is picked.

Business Component: Service Request
Field: Contact Last Name

The Pick Map object would be defined with the following properties:

Constrain FALSE
Field Account
Picklist Field Primary Account Name

Pick Map UpdOnlyIfNull child object would be defined as follows:

Field Account

The Account field will only be set to the primary account associated to the contact if the Account field on the service request is null.

NOTE: In Siebel applications version 7.5.3, an incorrect behavior will occur if you define only one Pick Map for a field and define a Pick Map UpdOnlyIfNull for this pick map. In this case, the Pick Map UpdOnlyIfNull will be ignored, therefore the pick map will always update the Pick Map field even if the Pick Map UpdOnlyIfNull field is non-null. Change Request 12-HQVK41 was logged to address this product defect. Change Request 12-HQVK41 has been fixed in Siebel applications version 7.7.

Because this issue only occurs when there is a single pick map defined for a field, you can work around this issue by adding a second pick map to the field, as follows:


5. /*whenever a new activity record is created in Account Activity List Applet, all its account related contacts should be added to the  Contacts MVG */



function WebApplet_PreInvokeMethod (MethodName)
{
            if(MethodName == "NewRecord")
   {
  
     var boaccount =TheApplication().ActiveBusObject();
     var bcaction = boaccount.GetBusComp("Action");
     var paraccount = boaccount.GetBusComp("Account");
     bcaction.NewRecord(NewAfter);
     var acrowid = TheApplication().GetSharedGlobal("AccounId");
     var bccontact = boaccount.GetBusComp("Contact");
     var bcaccon = boaccount.GetBusComp("Account Contact");
    
   with(bcaccon)
     {
      ActivateField("Contact Id");
      ActivateField("Account Id");
      SetViewMode(3);
      ClearToQuery();
      SetSearchSpec("Account Id", acrowid);
      ExecuteQuery();
     var count = CountRecords();
      }
     
      var firstrec = bcaccon.FirstRecord();
     
      while(firstrec != 0)
      {
      
       var conId=bcaccon.GetFieldValue("Contact Id");
       var MVGBc = bcaction.GetMVGBusComp("Contact Last Name");
       var assobc = MVGBc.GetAssocBusComp(); 
      
       with(assobc)
       {
       ActivateField("Id");
       SetViewMode(3);
       ClearToQuery();
       SetSearchSpec("Id",conId);
       ExecuteQuery();
       Associate(NewBefore);
       assobc=null;
       MVGBc=null;
       }

       firstrec = bcaccon.NextRecord();
      
       assobc=null;
       MVGBc=null; 
        
       }
        return(CancelOperation);      
       }



            return (ContinueOperation);

}





6.



var win = window.open(Name ,"Openwindow","");
 win.focus();




function Applet_PreInvokeMethod (name, inputPropSet)
{
  if (name == "LANURL")
  {
     
   //  var lsAcct_No_Dash = this.BusComp().GetFieldValue("Acct No Dash") ; 

            var OBSWPSMyGetFieldValue ;
            var PSinput = theApplication().NewPropertySet();
            var PSoutput = theApplication().NewPropertySet();
            PSinput.SetProperty("RowId", this.BusComp().GetFieldValue("Id"));
            PSinput.SetProperty("FieldName","Acct No Dash");
            PSinput.SetProperty("boName",this.BusObject().Name());
            PSinput.SetProperty("bcName",this.BusComp().Name());
            OBSWPSMyGetFieldValue = theApplication().GetService("WPSMyGetFieldValue");
            PSoutput = OBSWPSMyGetFieldValue.InvokeMethod("GetField",PSinput);  
    var lsAcctNo = PSoutput.GetProperty("DFieldValue");
            //alert(lsAcctNo) ; 

// var lsurl = "https://pics.nb.com/FormsLogin.asp?/PICSPrism2000/PMR/PMR.asp?prevnext=false&doDiv=false&acct_no="  + lsAcctNo ;
   var lsurl = "https://pics.nb.com/PICSPrism2000/PMR/PMR.asp?prevnext=false&doDiv=false&acct_no=" + lsAcctNo ;
//    var win = window.open(lsurl ,"_blank","");
            OpenWindow(lsurl) ;
    return ("CancelOperation");
  }
            return ("ContinueOperation");
}





genbscript c:\Program Files\Siebel\7.7\web client\BIN\enu\uagent.cfg c:\Program Files\Siebel\7.7\web client\PUBLIC\ENU ENU


Integration Platform
Technologies: Siebel
eBusiness Application
Integration Volume II




FAQ 1554: How Can You Set a Multi-value Group Record as Primary Through Siebel VB or eScript?

There is no function that allows users to display the content of a Siebel Visual Basic
or eScript variable in a calculated field.
However, a dynamic profile attribute can be used to achieve this.
For instance, assume the following piece of code fills a variable:
Siebel Visual Basic:
Dim myVar As String
myVar = "This is the content of this variable"
Siebel eScript:
var myVar;
myVar = "This is the content of this variable";
First, create a dynamic profile attribute and set its value with
the content of the variable. To do so, modify the preceding script as follow:
Siebel Visual Basic:
Dim myVar As String
myVar = "This is the content of this variable"
TheApplication.SetProfileAttr "myAttribute", myVar
Siebel eScript:
var myVar;
myVar = "This is the content of this variable";
TheApplication().SetProfileAttr("myAttribute", myVar);
It is now possible to reference this dynamic profile attribute in a calculated field.
The property 'Calculated Value' of the calculated field will
read the attribute with the following syntax:
Calculated Value: GetProfileAttr("myAttribute")
Please look at the Siebel Object Interfaces Reference to find further information on method GetProfileAttr and SetProfileAttr.
Please note that Siebel Personalization uses Profile Attributes. So in order to avoid conflict with attributes already defined by the system, ensure that the name of the attribute is not already used. For instance, use a string related to the user's company for the attribute's name ("MyCompanyName_AttributeName").








How Can You Use Siebel Scripting To Create or Delete a Many-to-Many MVG Record?



Siebel scripting, it is possible to create or delete through a multi-value group (MVG)
record if the parent and child have a many-to-many relationship. The general idea is to
simulate what the user does in the UI. Below are the steps to be followed in your script
and the equivalent steps that the user takes in the UI to associate a child record, and
to dissociate a child record.
For detailed information and code samples for the methods described below,
refer to Siebel Bookshelf version 7.7 > Object Interfaces Reference >
Interfaces Reference > Business Component methods.
In Siebel Tools version 7.5, you can also find the Bookshelf Guide within Siebel Tools
help.
In Siebel Tools, select Help > Contents and open the Object Interfaces Reference.

 Then select the Interfaces Reference section.


To Associate a Child Record
            Scripting Step            Equivalent User Action

1.         Get the parent business component instance.
            Enter a view driven by the parent business component.
2.         Query for the desired parent record.
            Select or query for the desired parent record.
3.         Instantiate the MVG business component using the GetMVGBusComp method
.           Open the pop-up MVG applet.
4.         Use the GetAssocBusComp method to instantiate the child business component.
             This is necessary because the parent and child have a many-to-many relationship.
            Click the New button on the MVG applet to bring up the Associate applet.
5.         Locate the child record that needs to be associated to the parent by running
            a query on the child business component.  
            Query, find and click on the record that is going to be associated in the
             Associate applet.
6.         Call Associate method on the child business component to perform the association
            Click the Add button to perform the association in the Associate applet.
7.         Destroy the child business component instance and MVG business component
            instance.Close the Associate applet and MVG applet.
            NOTE: This assumes that the child record already exists within
             the child business component. If you need to create a new child record and then
             associate it with the parent, you would execute the NewRecord method on the MVG
            business component. In this case you do not need to use the GetAssocBusComp
            method to instantiate the associate business component.



            To Dissociate a Child Record Scripting Step          Equivalent User Action


1.         Get the parent business component instance.        
            Enter a view driven by the parent business component.
2.         Query for the desired parent record.
            Select or query for the desired parent record.
3.         Instantiate the MVG business component using the GetMVGBusComp method.        
            Open the pop-up MVG applet.
4.         Locate the child record that needs to be removed from the parent by running
             a query on the MVG business component.           
            Query, find and click on the record that is going to be deleted in the MVG
            applet.
5.         Call DeleteRecord method on the MVG business component to
             remove the many-to-many relationship.
            Note that there is no specific method for dissociating a child record;
            the DeleteRecord method performs this action when in the context of an MVG
            applet. Click the Delete or Remove button on the MVG applet.
6.         Destroy the MVG business component instance.   Close the MVG applet.



            NOTE: In this case, it is not necessary to
            instantiate the child business component using the GetAssocBusComp method.
            The equivalent in the UI is that users do not need to launch the
             Associate applet to dissociate a child record from an MVG applet.

            Additional Tips

·           Make sure you reference the correct multi-value field (MVF)
            when using the GetMVGBusComp Method. Do not reference a multi-value link with
            this method.
·           When querying on the child business component, use the appropriate view mode
            setting to ensure you will retrieve the expected data.
            For more information about setting the view mode in scripted queries,
            refer to Siebel Bookshelf version 7.7 > Siebel Object Interfaces Reference >
            Interfaces Reference > Business Component Methods > SetViewMode Method.
·           If errors occur when trying to instantiate the Associate buscomp,
             check the No Insert property of the related buscomps, links, multi-value links,
            and applets.
·           Use the Business Component method ActivateField before executing the query
            for any fields where you are using the GetFieldValue business component method.
·           To manipulate records in a many-to-many relationship which does not have
            an MVG defined, you can use the GetBusObject and GetBusComp methods to retrieve
            the parent and child buscomps and perform the necessary transactions.
            For information on how to use GetAssocBusComp in this context, refer to
             Siebel Bookshelf version 7.7 > Siebel Object Interfaces Reference > Interfaces
            Reference > Business Component Methods > GetAssocBusComp Method.





Use extreme care when working with date variables. When working with date variables
extreme care has to be taken regarding the date format. GetFieldValue always returns the date in
dd/mm/yyyy format (eventually followed by the time). As a result, applying the CVDate() function,
which expects the regional setting, to the return value may cause an error. The
GetFormattedFieldValue method uses the regional settings of the user.s operating system. The
regional setting specifies the year with two digits in most cases, thereby creating the possibility of
Y2K non-compliance. For these reasons, you should use the following approach for performing date
arithmetic.
To perform date arithmetic
1 Retrieve the value of date fields with the GetFieldValue method. For more information, read
.GetFieldValue Method. on page 203.
2 Convert it into a date variable using the DateSerial() function.
3 Perform the required date arithmetic.
The following example is in Siebel VB.

Dim strDate as String, varDate as Variant
strDate = oBC.GetFieldValue("Date Field")
varDate =DateSerial(Val(Mid(strDate,7,4)),Val(Left(strDate,2)),_
Val(Mid(strDate,4,2)))


switch (FieldName)
{
case "Status":
{
var sysdate = new Date();
var sysdatestring = ((sysdate.getMonth() + 1) + "/" + sysdate.getDate() +
"/" + sysdate.getFullYear()+ " "+ sysdate.getHours() + ":" +
sysdate.getMinutes()+":" + sysdate.getSeconds());
this.SetFieldValue("Sales Stage Date",sysdatestring);
if ((FieldValue) == "Not Attempted")
{
if (this.GetFieldValue("Primary Revenue Amount") > 0)
this.SetFieldValue("Primary Revenue Amount",0);
}
break;
}
case "Revenue":
{
if (newrecSw =="Y")
{
newrecSw = "";
this.SetFieldValue("Account Revenue",(FieldValue));
}
break;
}
}



Created

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.