Pages

Sunday, May 7, 2017

Adding/Copying Accounts Team to Opportunity Sales team

I have used eScript for this function. There can be several other methods like dynamic candidate assignment to achieve the same functionality. But here I'm giving an  example code for copying the positions of Accounts Team of an Account to the Sales Team of an Opportunity, while associating the account to an Opportunity.

This is written under BusComp server scripts in Opportunity BusComp.

Below is the code and comments will explain the functionality within the script.


function BusComp_SetFieldValue (FieldName)
{
//Added to copy Accounts team to Opportunity Sales Team while associating an account to opportunity

if (FieldName == "Account")
{
var OptyAccountId = GetFieldValue("Account Id");

//First check whether the Account is input, otherwise
//Prevent code execution while removing the account from the opportunity
if (OptyAccountId)
{
var boBusObj = TheApplication().GetBusObject("Account");
var bcAcct = boBusObj.GetBusComp("Account");
var sSalesTeam ='';

with(bcAcct)
{
ClearToQuery();
SetViewMode(AllView);
ActivateField("Sales Rep");
SetSearchSpec("Id", OptyAccountId);
ExecuteQuery(ForwardOnly)
if(FirstRecord())
{
//the account was found. Now cycle through the positions

var bcMVG = bcAcct.GetMVGBusComp("Sales Rep");
bcMVG.ActivateField ("Position Id");
var isRec = bcMVG.FirstRecord();

while(isRec)
{

var PosId = bcMVG.GetFieldValue("Position Id");

var optyMVG = this.GetMVGBusComp("Sales Rep");

//search in optyMVG whether the position which is there in account already exist in oppotunity.

optyMVG.ClearToQuery();
optyMVG.SetViewMode(AllView);
optyMVG.ActivateField("Position Id");
optyMVG.SetSearchSpec("Position Id",PosId);
optyMVG.ExecuteQuery(ForwardOnly)
var isRecopty = optyMVG.FirstRecord();
//If the position record is not there in oppotunity;
if (isRecopty == false)
{
//Add position to oppotunity
var bcAssoc = optyMVG.GetAssocBusComp();
bcAssoc.ClearToQuery();
bcAssoc.SetViewMode(AllView);
bcAssoc.ActivateField("Position Id");
bcAssoc.SetSearchSpec("Position Id",PosId);
bcAssoc.ExecuteQuery(ForwardOnly)
var isRecpos = bcAssoc.FirstRecord();
if (isRecpos)
{
bcAssoc.Associate(NewAfter);
}
}
isRec = bcMVG.NextRecord();
}
}
}
}
}
}

Hope this helps...
When write a new script and save, Siebel tools get stuck

Hi all,

This issue came for me while I was writing a Buscomp Script and due to some issue in the script, Siebel Tools got stuck. I tried to close and reopen Tools, but when ever I go to Edit Server Script of that particular BusComp, again tools get stuck.

So the Solution, which I found is this;

We will take an example of 'Opportunity' Business Component. If we write some bogus script on BusComp_SetFieldValue method, then here is the steps you can resolve the issue.

1. Once tools get stuck, reopen Siebel tools
2. Search for Business Component 'Opportunity'
3. Go to 'BusComp Server Script' (By default this will not appear in object explorer. You will have to enable it from View --> Options --> Object Explorer)
4. Select the particular record for 'BusComp_SetFieldValue'
5. Click on the 'Script' field and edit the script to remove the issue or totally delete the script from there and save record

Issue should be resolved... ⏩