SiebelGuide.com/siebelblogs

Siebel Blogs, News, Events, Tips and Tricks
Filed under How To, Tips&Tricks, eScript, All, Configuration

While I was working on eScript I came across the method GetMVGBusComp which is one of Best Practices in eScripting and I thought of posting it here. Details about this method below.

Tip 11:Use GetMVGBusComp Method to get the MVG records

As the method name suggests it gets the Business Component of the record that MVG is based on. This is a very helpful Method that would save a several lines of unnecessary code.

For example, we have Accounts and there are Sales Reps associated to each of these accounts. These Sales Reps are based on Position BC. Position BC is the MVG Business Component of Account BC. The requirement is to get all the sales rep associated to the details of all the sales rep associated to this account using eScript. Now a developer who is writing this eScript and not aware of this Method would write an eScript something like this.

  1. Get Account Row ID
  2. Get Account Position BC
  3. Query for Account ID
  4. Get the corresponding Position Id
  5. Get Postion BC
  6. Query for that Postion Id from step 4
  7. Get Employee details from this Position BC

Instead we could write something like this

  1. Get Account RowId
  2. Get all the sales rep records using GetMVGBusComp
  3. Get Employee details from this Position BC.

Here is the code for your reference.


oAccBC = oAccBO.GetBusComp("Account");

//Get the corresponding Sales Rep Bus Comp — eScript Best practice here.
var oAccPostnBC = oAccBC.GetMVGBusComp("Sales Rep");

//Add search spec to already filtered records
//No Need to get the Sales Rep that are associated to only this account
//The Method already gets sales rep that belongs to only this account
//Do not to use ClearToQuery here.
//You could add more Search Spec if you desire
oAccPostnBC.SetSearchSpec("Position Type","Partner Sales Rep");
oAccPostnBC.ExecuteQuery();
var rAccPostn = oAccPostnBC.FirstRecord();

//Here I am getting all the email Addresses
while(rAccPostn)
{
sEmailAddr = sEmailAddr + oAccPostnBC.GetFieldValue("Active Email"a) + ";";
rAccPostn = oAccPostnBC.NextRecord();
}


Tip 12: Verify Existence of Valid Record after Querying

After you execute the method ExecuteQuery() make sure to check if there is at least one valid record that you desire otherwise it might result in an invalid scripting. For example in the code above before I get the email addresses I check there is a valid record returned from my ExecuteQuery Method using the while statement. Otherwise GetFieldValue on the BC record will behave weird by throwing error. Also you could use IF statement to check if you expect the result to have just one record.

Hope this post has helped you. If you any tips that you would like to share, please email me using the Participate form.

Related posts(Auto Generated):

  1. eScripting Best Practices - Part3
  2. eScript Best Practices - Part6
  3. PropertyExists Method in Siebel eScript
  4. eScripting Best Practices - Part4
  5. eScripting Best Practices - Part5

Posted by Sridhar on Monday, September 15th, 2008


Page copy protected against web site content infringement by Copyscape
You can follow any responses to this entry through the magic of "RSS 2.0" and leave a trackback from your own site.

Post A Comment

Recent Posts 

Recent Comments:

  • Sridhar: LDAP mechanism should be handled by Siebel Server. So I dont know why this would matter. I havent tested with...
  • Nitin: Hi, Nice post, however i think this will not work in the case where we are using any aunthentication methods like...
  • Nitin: Hey, Its a nice post but this cannot work if you are using any authetication method like LDAP or something…or...
  • Sridhar: Check Siebel Book Shelf. Siebel Business Process FrameWork workflow guide->Invoking Workflow processes page...
  • Nitin Kumar Jain: Can I control whether the Workflow invoked by the RTE is Synchronous or Asynchronous call. If yes, how?...