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
No comments:
Post a Comment