Retrieve Primary Keys in TLS

By | December 7, 2013

Table Level Scripts (TLS) are an alternative method of creating SQL triggers that can be performed in Sage CRM system. Table Level Script (TLS) are used to perform various operations after inserting records, updating or deleting records in Sage CRM. To perform operations, it is necessary to fetch the primary ID of the current entity in TLS. However, most of the users find it difficult to retrieve the Primary Keys in TLS. To find the resolution, please continue to read below:

The New Stuff: Creating Order with existing Opportunity in GUMU™ Integration

Consider an example where you want to retrieve Primary entity ID of Cases table and use it for further development using a Table Level Script. Here are the ways with which you can achieve the same.

Way 1:
//’Get Case ID
var sCaseid = new String(CRM.GetContextInfo(“Case”,”case_caseid”));

//’Get Case Data
objCase = CRM.FindRecord(“cases”,”case_caseid=”+ sCaseid)

Way 2:
//’Get Case ID
var sCaseid = new String(Values(“case_caseid”));

//’Get Case Data
objCase = CRM.FindRecord(“cases”,”case_caseid=”+ sCaseid)

Way 3:
Now if you print WhereClause variable in the TLS, you will get the value something as shown below.
case_caseid=<< Primary field value of Cases entity>>

In this case, you can fetch case data as follows.
//’Get Case Data
objCase = CRM.FindRecord(“cases”, WhereClause)

All the above syntaxes can be used on PostInsert, Update and Delete functions of TLS. Moreover, the same set of instructions can be applied for other similar entities.

About Us

Greytrix is one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix has some unique integration solutions for Sage CRM with Sage ERP’s (Sage X3Sage 100Sage 500 and Sage 300).We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users and Sage PSG worldwide.Greytrix helps in migrating to Sage CRM from ACTGoldmine and other CRM’s.

For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.

Also Read:
1) Quick look on Sage CRM tables
2) Writing Table Level Script a hectic job? – Try this instead…
3) Retrieve deleted records in Sage CRM
4) How to access views of Different Database in CRM
5) Remove Secterr Field from Secondary Entity