Associate Method for a Business Component

The Associate method creates a new many-to-many relationship for the parent object through an association business component. This method does not return any information. For more information, see GetAssocBusComp Method for a Business Component.

Format

BusComp.Associate(whereIndicator)

The following table describes the arguments for the Associate method.

Argument Description

whereIndicator

You must use one of the following predefined constants:

  • NewBefore

  • NewAfter

For more information, see Use Constants to Standardize Code.

Usage

To set field values on a child record that is associated with a parent record, use the context of the multivalue group business component.

Used With

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

Examples

The following VB example updates the Opportunity Assignment Type field. The parent business component can be any business component that includes the Sales Rep multivalue 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 when the Last Name is Abanilla, and then adds a new organization named CKS Software to the Organization multivalue group:

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(ForwardOnly);
   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

   oAssocBC = null;
   oMvgBC = null;

} // With ContactBC

ContactBC = null;
ContactBO = null;

Related Topics

For more information, see the following topics: