Import into Creatio

From Apps for Creatio
Revision as of 08:32, 5 June 2025 by CreatioWikiSysop (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Using JINT mode you can insert data. The example below creates and Account and Contact record. Then it updates the Account making the Contact the Primary contact for the Account.


You can see use of the method "getguid" which allows you to map Creatio Lookup record Guids.



SAMPLE SCRIPT

var account_name = "Acme Consulting";

var account_category = "B";

var account_industry = "Advertising";

//get any guid values

var account_categoryGUID = di.getguid("AccountCategory",account_category);

var account_industryGUID = di.getguid("AccountIndustry",account_industry);

var creatioRecord = CreatioRecord('Account');

creatioRecord.Set("AccountCategoryId", account_categoryGUID);

creatioRecord.Set("IndustryId", account_industryGUID);

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']);

}else if (cRecord && cRecord.Rows.Count==0){

    creatioRecord.Set("Name", account_name);

    var newId=creatioRecord.Insert();

    var creatioRecord_contact = CreatioRecord('Contact');

    creatioRecord_contact.Set("AccountId",newId);

    creatioRecord_contact.Set("Name","Michael Scalea");

    creatioRecord_contact.Set("JobTitle","Owner");

    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);

}