Import into Creatio: Difference between revisions

From Apps for Creatio
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
 
Line 1: Line 1:
Here we cover iIf you wanted to import data from say a SQL database into Creatio.
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.  


In our example we will use a Sage 300 database. Our aim is to import AR_Customer records into Creation Accounts and Contacts.
 
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);
 
}

Latest revision as of 08:32, 5 June 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);

}