Monday, September 7, 2009

Setting the SSA Primary Field

When I started configuring Siebel, I was mostly self-taught, which means that I usually settled for the first way I found of accomplishing my goal. Setting the primary record on a multi-value group through script is one example.

My method: query for the record I needed in the child buscomp, obtain the row id, and then use that row id to update the primary id field of the parent. For example, if I needed to set the primary position on the Account buscomp, I would begin by looking up the position id, then I would use a SetFieldValue statement to set the Primary Position Id with the id I had retrieved.

Wrong approach! That is the dangerous way. A scripting error will potentially corrupt your database in the same way direct sql could, by breaking its referential integrity. Directly setting a primary id field is not supported by Oracle.

The feature I didn't understand, which makes the process much easier and safer, is a system field called SSA Primary. You may have noticed this field in MVG Applet configurations. It's a system field, much like Created or Id, but it is different in two important ways:
  1. The SSA Primary field does not correspond directly to a database column.
  2. The SSA Primary field is editable.
Like other system fields, it is not listed in the Fields object in Tools, and you don't have to explicitly activate it in scripting.

Using the SSA Primary field, here is the correct way to use script to set the primary on an MVG, as recommended by Oracle:
  1. Get the MVG business component using the BusComp.GetMVGBusComp method.
  2. Use BusComp.SetSearchSpec and BusComp.ExecuteQuery methods to locate the correct record on the MVG business component.
  3. Set the SSA Primary field with the statement BusComp.SetFieldValue("SSA Primary Field", "Y"), substituting the actual business component variable name.
  4. Use BusComp.WriteRecord on the parent business component. This is because the Primary Id field is on the parent.
Some versions of Siebel Tools will give a semantic warning when you check the syntax after you try to set the SSA Primary field. This is a Siebel bug, and this warning can be safely ignored.

Update - Fixed a typo caught by commenter Duarte: Above instructions previously contained BusComp.SetFieldValue("SSA Primary", "Y") instead of BusComp.SetFieldValue("SSA Primary Field", "Y"). Thanks Duarte!


Seema said...
This comment has been removed by the author.
Jim Tanner-Uicker said...

You have to query the MVG buscomp to locate the record you want to be primary. Otherwise, you could loop through them with NextRecord. You wouldn't be setting the primary randomly, so you need to somehow query the MVG buscomp.

Once you have the correct record in the MVG buscomp, you need to use SetFieldValue to update the SSA Primary field on the selected record in the MVG buscomp.

The only operation you need to do on the parent buscomp is WriteRecord.

Duarte said...


Actually is

BusComp.SetFieldValue("SSA Primary Field", "Y"), instead of
BusComp.SetFieldValue("SSA Primary", "Y")


Jim Tanner-Uicker said...

Thanks, Duarte. I've updated the post.

vishnu said...

this is good approch
you can set seachspec then it returns records in IF(FirstRecord()) returns true value ..
then you will select as SSA primary ID field. but search spec is based on Primary key
I think you have to apply searchspec then srotspec then you can change the order of the returning records so it will give you appropriate records then using PICK() method ..
you get this value..
any issues on this comment plese reply me ..
SO that I can learn on this things ..\

Jim Tanner-Uicker said...

Hi Vishnu,

I believe you are thinking of a picklist, and not an multi-value group. Theoretically, it would be possible to create a picklist using the MVG business component as the pick business component, and use a pick map to set the MVG primary. However, if you are setting the primary through script and if there are no other factors involved, this extra configuration doesn't make sense to me.



Richard C. Lambert said...

I think I have never seen such blogs ever before that has complete things with all details which I want. So kindly update this ever for us.
social media marketing westchester New York