Import into Creatio: Difference between revisions
Created page with "Here we cover iIf you wanted to import data from say a SQL database into Creatio. In our example we will use a Sage 300 database. Our aim is to import AR_Customer records into Creation Accounts and Contacts." |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
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); | |||
} | |||
---- | |||
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); | |||
Latest revision as of 09:54, 3 October 2025
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);
}
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);