Siebel Object Interfaces Reference > Interfaces Reference > Business Component Methods >

Associate Method


The Associate method creates a new many-to-many relationship for the parent object through an association business component (see GetAssocBusComp).

Syntax

BusComp.Associate(whereIndicator)

Argument
Description

whereIndicator

This argument should be one of the following predefined constants or the corresponding integer: NewBefore (0) or NewAfter (1), as in NewRecord.

Returns

Not applicable

Usage

To set field values on a child record that has been associated to a parent record, use the context of the MVGBusComp.

Used With

COM Data Control, COM Data Server, Java Data Bean, Mobile Web Client Automation Server, Server Script

Example

The following VB example updates the Opportunity Assignment Type field. The parent business component can be any business component that includes the Sales Rep multi-value group.

Dim oParentBC as BusComp
Dim oMvgBC as BusComp
Dim oAssocBC as BusComp

Set oParentBC = me.BusComp
Set oMvgBC = OpBC.GetMVGBusComp("Sales Rep")
Set oAssocBC = oMvgBC.GetAssocBusComp
With oAssocBC
   .SetSearchSpec "Id", newPosId
   .ExecuteQuery
   .Associate NewAfter
End With

oMvgBC.SetFieldValue "Opportunity Assignment Type", "NewType"
oMvgBC.WriteRecord
Set oAssocBC = Nothing
Set oMvgBC = Nothing
Set oParentBC = Nothing

The following Siebel eScript example finds a contact with the Last Name = "Abanilla", and adds a new organization named "CKS Software" to its Organization MVG.

var ok = 0;
var ContactBO= TheApplication().GetBusObject("Contact");
var ContactBC = ContactBO.GetBusComp("Contact");
with (ContactBC)
{
   ClearToQuery();
   SetViewMode(AllView);

   // Searches by Last Name
   SetSearchSpec ("Last Name", "Abanilla");
   ExecuteQuery();
   if (FirstRecord())
   {

      // Instantiates Organization MVG
      var oMvgBC = GetMVGBusComp("Organization");
      var oAssocBC = oMvgBC.GetAssocBusComp();
      oAssocBC.ClearToQuery();
      oAssocBC.SetSearchSpec("Name", "CKS Software");
      oAssocBC.ExecuteQuery ();

      // Checks if the Organization was found
      if (oAssocBC.FirstRecord())
      {

         // Organization was found
         try
         {
            oAssocBC.Associate(NewAfter);
            ok = 1;
         }

         catch (e)
         {
            ok = 0;
            TheApplication().RaiseErrorText("Error Associating new Organization");
         }

      } // if oAssocBC.FirstRecord

   } // if FirstRecord

} // With ContactBC

See Also

NewRecord Method
FirstSelected Method
GetMVGBusComp Method

Siebel Object Interfaces Reference