DI Jint: Difference between revisions
From Accelerator for SageCRM
(Created page with "There are specific commands in the Javascript Engine (JINT) relating to SageCRM Only. getID - This is used where you have the "Name" value and need the ID. You would use this for an integration where Id's would not map but you could map the Names. Only one result is returned so this depends on the Name value being unique. Otherwise use querydb. - Parameters (a) COLLECTION (b) FILTER - returns ID value EG >var _compId = di.getID('Company', 'Union Computer'); 2...") |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
getID - This is used where you have the "Name" value and need the ID. You would use this for an integration where Id's would not map but you could map the Names. Only one result is returned so this depends on the Name value being unique. Otherwise use querydb. | getID - This is used where you have the "Name" value and need the ID. You would use this for an integration where Id's would not map but you could map the Names. Only one result is returned so this depends on the Name value being unique. Otherwise use querydb. | ||
- Parameters (a) COLLECTION (b) FILTER | |||
- returns ID value | - returns ID value | ||
| Line 18: | Line 18: | ||
>var val=di.getlookupcode("Company", "Comp_Sector","Construction") | >var val=di.getlookupcode("Company", "Comp_Sector","Construction") | ||
---- | |||
Example | |||
= SageCRM Record Examples = | |||
== 1. SageCRM - Company == | |||
=== Insert === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Company'); | |||
sageRecord.Set("Comp_Name", "TestCompany"); | |||
sageRecord.Set("Comp_Status", "Active"); | |||
sageRecord.Set("Comp_Type", "Prospect"); | |||
sageRecord.Set("Comp_Sector", "Finance"); | |||
var key = sageRecord.Insert(); | |||
di.display(key); | |||
</pre> | |||
=== Update === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Company'); | |||
var key = di.getguid('Company', 'TestCompany'); | |||
sageRecord.Set("Comp_Name", "Updated:TestCompany"); | |||
sageRecord.Update(key); | |||
</pre> | |||
=== Delete === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Company'); | |||
var key = di.getguid('Company', 'Updated:TestCompany'); | |||
sageRecord.Delete(key); | |||
</pre> | |||
== 2. SageCRM - Person == | |||
=== Insert === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Person'); | |||
sageRecord.Set("Pers_FirstName", "TestFirstName"); | |||
sageRecord.Set("Pers_LastName", "TestLastName"); | |||
sageRecord.Set("Pers_CompanyId", "1241"); | |||
var key = sageRecord.Insert(); | |||
di.display(key); | |||
</pre> | |||
=== Update === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Person'); | |||
var key = di.getguid('Person', 'TestFirstName'); | |||
sageRecord.Set("Pers_FirstName", "TestFirstName-Updated"); | |||
sageRecord.Set("Pers_LastName", "TestLastName-Updated"); | |||
sageRecord.Update(key); | |||
</pre> | |||
=== Delete === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Person'); | |||
var key = di.getguid('Person', 'TestFirstName-Updated'); | |||
sageRecord.Delete(key); | |||
</pre> | |||
== 3. SageCRM - Cases == | |||
=== Insert === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Cases'); | |||
sageRecord.Set("Case_product", ""); | |||
sageRecord.Set("case_description", "TestCaseDescription"); | |||
sageRecord.Set("Case_ReferenceId", "Abc-123"); | |||
var key = sageRecord.Insert(); | |||
di.display(key); | |||
</pre> | |||
=== Update === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Cases'); | |||
var key = di.getguid('Cases', 'TestCaseDescription'); | |||
sageRecord.Set("Case_ReferenceId", "Abc-123-Updated"); | |||
sageRecord.Update(key); | |||
</pre> | |||
=== Delete === | |||
<pre> | |||
jint di | |||
var sageRecord = SageCRMRecord('Cases'); | |||
var key = di.getguid('Cases', 'TestCaseDescription'); | |||
sageRecord.Delete(key); | |||
</pre> | |||
Latest revision as of 13:09, 3 June 2026
There are specific commands in the Javascript Engine (JINT) relating to SageCRM Only.
getID - This is used where you have the "Name" value and need the ID. You would use this for an integration where Id's would not map but you could map the Names. Only one result is returned so this depends on the Name value being unique. Otherwise use querydb.
- Parameters (a) COLLECTION (b) FILTER - returns ID value
EG
>var _compId = di.getID('Company', 'Union Computer');
2. getLookupCode - In Sage CRM some fields are lookups/selects and they use codes and translations, to get the translation value from given code.
- Parameters (a) COLLECTION (b) SOURCE_FIELD (c) SOURCE_CODE - returns translation value from COLLECTION
EG
>var val=di.getlookupcode("Company", "Comp_Sector","Construction")
Example
SageCRM Record Examples
1. SageCRM - Company
Insert
jint di
var sageRecord = SageCRMRecord('Company');
sageRecord.Set("Comp_Name", "TestCompany");
sageRecord.Set("Comp_Status", "Active");
sageRecord.Set("Comp_Type", "Prospect");
sageRecord.Set("Comp_Sector", "Finance");
var key = sageRecord.Insert();
di.display(key);
Update
jint di
var sageRecord = SageCRMRecord('Company');
var key = di.getguid('Company', 'TestCompany');
sageRecord.Set("Comp_Name", "Updated:TestCompany");
sageRecord.Update(key);
Delete
jint di
var sageRecord = SageCRMRecord('Company');
var key = di.getguid('Company', 'Updated:TestCompany');
sageRecord.Delete(key);
2. SageCRM - Person
Insert
jint di
var sageRecord = SageCRMRecord('Person');
sageRecord.Set("Pers_FirstName", "TestFirstName");
sageRecord.Set("Pers_LastName", "TestLastName");
sageRecord.Set("Pers_CompanyId", "1241");
var key = sageRecord.Insert();
di.display(key);
Update
jint di
var sageRecord = SageCRMRecord('Person');
var key = di.getguid('Person', 'TestFirstName');
sageRecord.Set("Pers_FirstName", "TestFirstName-Updated");
sageRecord.Set("Pers_LastName", "TestLastName-Updated");
sageRecord.Update(key);
Delete
jint di
var sageRecord = SageCRMRecord('Person');
var key = di.getguid('Person', 'TestFirstName-Updated');
sageRecord.Delete(key);
3. SageCRM - Cases
Insert
jint di
var sageRecord = SageCRMRecord('Cases');
sageRecord.Set("Case_product", "");
sageRecord.Set("case_description", "TestCaseDescription");
sageRecord.Set("Case_ReferenceId", "Abc-123");
var key = sageRecord.Insert();
di.display(key);
Update
jint di
var sageRecord = SageCRMRecord('Cases');
var key = di.getguid('Cases', 'TestCaseDescription');
sageRecord.Set("Case_ReferenceId", "Abc-123-Updated");
sageRecord.Update(key);
Delete
jint di
var sageRecord = SageCRMRecord('Cases');
var key = di.getguid('Cases', 'TestCaseDescription');
sageRecord.Delete(key);