Import into Sage CRM

From Accelerator for SageCRM
Revision as of 11:41, 2 March 2026 by Sagecrmw (talk | contribs) (Created page with "Using JINT mode you can insert data. The example below creates a Company and Person record. Then it updates the Company making the Contact the Primary contact for the Company. You can see use of the method "getID" which allows you to map SageCRM Lookup record Codes. ---- '''SAMPLE SCRIPT''' var account_name = "Acme Consulting"; var _source = "Import"; var _status = "Active"; //get any lookup code values (useful if mapping from another system w...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using JINT mode you can insert data. The example below creates a Company and Person record.

Then it updates the Company making the Contact the Primary contact for the Company.


You can see use of the method "getID" which allows you to map SageCRM Lookup record Codes.



SAMPLE SCRIPT

   var account_name = "Acme Consulting";
   var _source = "Import";
   var _status = "Active";
   //get any lookup code values (useful if mapping from another system where then code and translation do not match)
   var comp_source = di.getLookup("comp_source",_source);
   var comp_status  = di.getLookup("comp_status ",_status);
   var SageCRMRecordObj= SageCRMRecord('Company');
   SageCRMRecordObj.Set("comp_source", comp_source);
   SageCRMRecordObj.Set("comp_status", comp_status);

var accountFilter="Name eq '"+account_name+"'";

var cRecord=di.querydb("Account",accountFilter,"Id");

var accountId=null;

if (cRecord && cRecord.Rows.Count==1)

{

   //only do if count is one
   var updated=creatioRecord.Update(cRecord.Rows[0]['Id']); 
   var newCompanyId=SageCRMRecordObj.Insert();


   var SageCRMRecordObjP= SageCRMRecord('Person');

    SageCRMRecordObjP.Set("Pers_companyid",newCompanyId);

    SageCRMRecordObjP.Set("pers_firstname","Michael");

    SageCRMRecordObjP.Set("pers_lastname","Scalea");

    var newContactId=creatioRecord_contact.Insert();

    var creatioRecord_ac = CreatioRecord('Account');

    creatioRecord_ac.Set("PrimaryContactId",newContactId);

    creatioRecord_ac.update(newId);

}else{

    di.display("****Duplicate Account Found****:"+account_name);

}


SetNumeric example

So whenever we wants to set value as Numeric/Float then we we need to use creatioRecord.SetNumeric('Price',12.40);

EG

var creatioRecord = CreatioRecord('Product');

creatioRecord.Set('Name', 'TestProductName7');

creatioRecord.Set('Code', 'Test007');

creatioRecord.SetNumeric('Price', 15.30);

var newId=creatioRecord.Insert();

di.display(newId);

File:Jint creatio demo.png