Compartilhar via


Performing MVG operations using the Siebel Adapter

The RTM version of Siebel Adapter no longer supports the MVG operations – Associate, Dissociate and Query_*. The reason for dropping support for these operations is a memory leak in Siebel library that the adapter uses to communicate with Siebel. We are actively following up with Siebel to get this issue (SR# - 38-3489322221) resolved. In the mean time you can use the following alternate approach.

 

Before the adapter can be used to perform the MVG operations, users must manually obtain some information from Siebel. You can use Siebel Tools to get this information, which includes the MVG business component name and the foreign key fields in that. Below is a step by step description of how to go about finding that information.

 

1. Obtain the name of the Multi-Value Link based on the specific MVG field.

For example if the field is “Contact Id” in “Action” business component, the name of the MVL is “Contact”

2. From the Multi-Value Link, obtain the name of the Link

For the above example, the name of the Link is “Action/Contact”

3. From the Link, obtain the name of the Intersection Table, Inter Parent Column and Inter Child Column and the Primary ID Field. Note that if the Source Field and/or Destination Field are specified, they will be the primary keys, instead of Id, in the parent and child records.

For the above example, the name of the Intersection Table is “S_ACT_CONTACT”, Inter Parent Column is “ACTIVITY_ID”, Inter Child Column is “CON_ID” and Primary ID Field is “Primary Contact Id”. Both the Source Field and Destination Field are not specified meaning the primary key field is “Id” for either business components.

4. Now obtain a business component whose base table is the above Intersection Table. This would be the MVG business component. Note that if there are more than one, you will have to use some context to figure out the right one.

For the above example, the business component is “Action Contact”.

5. Also find the fields in the MVG business component that obtain their values from the Inter Parent Column and Inter Child Column obtained above. These will be the foreign keys for the parent and child record respectively.

For the above example, the field names are “Activity Id” and “Contact Id”

6. Now obtain a business object that contains this business component.

For the above example, the business object is “Contact”

 

Once we have the above information, the MVG operations can be performed by directly operating on the MVG business component using the foreign key fields. In the above example, the 3-tuple would be “Action Contact”, “Activity Id” and “Contact Id”.

 

1. Associate

 

To associate a specific record of the parent BC with a specific record of child BC, insert a record in MVG BC by setting the foreign key fields appropriately. For example if one wants to associate a record of Action with Id = “a” with a record of Contact with Id = “c”, insert a record in “Action Contact” with Activity Id set to “a” and Contact Id set to “c”.

 

        /// <summary>

        /// Associate a "Contact" record with an "Action" record

        /// </summary>

        /// <param name="mvg">Proxy client for the MVG business component</param>

        /// <param name="activityId">Unique identifier for the "Action" record</param>

        /// <param name="contactId">Unique identifier for the "Contact" record</param>

        /// <returns>Id of the newly created record in MVG BC</returns>

        private static string

            Associate(

                BusinessObjects_Contact_ActionContact_OperationClient mvg,

                string activityId,

                string contactId

            )

        {

            try

            {

                /// Insert a record into the MVG BC after setting the

    /// "Activity Id" & "Contact Id"

                ActionContactInsertRecord[] insertRec = new ActionContactInsertRecord[1];

                insertRec[0] = new ActionContactInsertRecord();

                insertRec[0].ActivityId = activityId;

                insertRec[0].ContactId = contactId;

                string[] id = mvg.Insert(insertRec);

                return id[0];

            }

            catch (Exception e)

            {

                Console.WriteLine("ERROR: Associate - " + e.Message);

            }

            return null;

   }

 

Once a record has been associated, if you want to make this as the primary association, you need to set the Primary ID Field as well. For the above example, to make the new associated Contact record with Id = “c” as the primary association for the Action record, we will set the “Primary Contact Id” field in the Action record to “c”.

 

        /// <summary>

        /// Set the <Primary Id> field in the "Action" record to create a

        /// primary "Contact" for this "Action".

        /// </summary>

        /// <param name="action">Proxy client for the "Action" business component</param>

        /// <param name="activityId">Value of the foreign key field for the "Action" record</param>

        /// <param name="contactId">Value of the foreign key field for the "Contact" record</param>

        /// <returns></returns>

        private static bool

            SetPrimaryAssociation(

                BusinessObjects_Action_Action_OperationClient action,

                string activityId,

                string contactId

            )

        {

            try

            {

                /// Set the Primary Id field "Primary Contact Id" in "Action"

                /// to the Id of Contact record

                ActionUpdateRecord[] updateRec = new ActionUpdateRecord[1];

                updateRec[0] = new ActionUpdateRecord();

                updateRec[0].Id = activityId;

                updateRec[0].PrimaryContactId = contactId;

                action.Update(null, updateRec);

                return true;

            }

            catch (Exception e)

            {

                Console.WriteLine("ERROR: SetPrimaryAssociation - " + e.ToString());

            }

            return false;

   }

 

 

2. Dissociate

 

To dissociate a specific record of the parent BC from a specific record of child BC, delete the record from MVG BC found by using a search expression built using the 2 foreign key fields. For example if one wants to dissociate a record of Action with Id = “a” from a record of Contact with Id = “c”, delete a record from “Action Contact” using the search expression “[Activity Id] LIKE a and [Contact Id] LIKE c”.

 

        /// <summary>

        /// Dissociate a "Contact" record from an "Action" record

        /// </summary>

        /// <param name="mvg">Proxy client for the MVG business component</param>

        /// <param name="activityId">Unique identifier for the "Action" record</param>

        /// <param name="contactId">Unique identifier for the "Contact" record</param>

        /// <returns>Id of the record deleted from the MVG BC</returns>

        private static string

            Dissociate(

                BusinessObjects_Contact_ActionContact_OperationClient mvg,

                string activityId,

                string contactId

            )

        {

            try

            {

                /// Delete the record where "Activity Id" and "Contact Id"

                /// matche the specified values

                string searchExpr = "[Activity Id] LIKE \"" + activityId + "\" and [Contact Id] LIKE \"" + contactId + "\"";

                string[] id = mvg.Delete(null, null, searchExpr);

                return id[0];

            }

            catch (Exception e)

            {

                Console.WriteLine("ERROR: Dissociate - " + e.Message);

            }

            return null;

        }

 

Note that if the primary record is getting dissociated, you will need to update the Primary ID field to another associated record or if there are none, you will need to clear it. See “SetPrimaryAssociation” code sample above for how to do this.

 

3. Query associated

 

To query records of child BC that are associated with a specific record of the parent BC, query the MVG BC using a search expression built using the foreign key of parent BC. For example, if one wants to query records of Contact associated with a record of Action, whose Id = “a”, query “Action Contact” using the search expression “[Activity Id] LIKE a”

 

       /// <summary>

        /// Query the "Contact" records associated with a specific "Action"

        /// record

        /// </summary>

        /// <param name="mvg">Proxy client for the MVG business component</param>

        /// <param name="activityId">Unique identifier for the "Action" record</param>

        /// <returns>Ids of the associated "Contact" records</returns>

        private static List<string>

            QueryAssociatedContact(

                BusinessObjects_Contact_ActionContact_OperationClient mvg,

                string activityId

            )

        {

            List<string> id = new List<string>();

            try

            {

      /// Query the MVG business component for all records where

                /// "Activity Id" is set to the specified value

                ActionContactQueryInputRecord queryIn = new ActionContactQueryInputRecord();

                queryIn.SearchExpr = "[Activity Id] LIKE \"" + activityId + "\"";

                ActionContactQueryRecord[] queryOut = mvg.Query(null, queryIn);

                foreach (ActionContactQueryRecord rec in queryOut)

                {

                    id.Add(rec.ContactId);

                }

            }

            catch (Exception e)

            {

                Console.WriteLine("ERROR: Query_Contact - " + e.Message);

            }

            return id;

        }