Import contacts from LDAP to SM without using Connect-it (Only operators created)

1 - The slapconfig must be configured with LDAP parameters. (Operators must be synchronized).

2- Search the library script (triggerContactsOperators) and locate the function syncContactToOperator.

3- add the lines in red bold, considering that you must place your company information among "".

function syncContactToOperator(IdRecord, record, oldrecord)

{

      var doSync = checkIfOperatorChanged(IdRecord, record, oldrecord);

     

      if (doSync)

      {

            var ConId = record.contact_name;

            var fContact = new SCFile("contacts");

            var rc = fContact.doSelect("contact.name=\"" ConId "\"");

            if ( rc == RC_SUCCESS )      

            {

           

                  fContact.full_name = record.full_name;

                  fContact.email = record.email;

                  fContact.operator_id = record.name;

                  fContact.fax_phone = record.fax;

                                   

                  var ret = new Datum();

                  system.functions.rtecall("trigger", ret, 0);

                  var rc=fContact.doUpdate();                    

                  system.functions.rtecall("trigger", ret, 1);

                  if (rc==RC_SUCCESS)

                  {

                        themessage2=system.functions.scmsg(102, "ScriptLibrary", [fContact.contact_name]);

                        print(themessage2);

                  }

            }    

            else

            {

                  themessage2=system.functions.scmsg(103, "ScriptLibrary", [ConId]);

                  print(themessage2);          

            }

            //inicio

            //@wwwific

            print( "Creating new contact record..." );

            var tblOperator = new SCFile("operator");

            var lstOperator = tblOperator.doSelect("name=\"" IdRecord.name "\"");

                  if (lstOperator == RC_SUCCESS){

                        var fname = tblOperator.full_name;

                        var ccname = tblOperator.contact_name;

                        var email = tblOperator.email;

                        var redname = tblOperator.name;

                  }

 

            //Create new contact

            var newContact = new SCFile("contacts");

            newContact.user_type = "";

            newContact.dept_name = "";

            newContact.dept = "";

            newContact.dept_id = "";

            newContact.corp_structure = "";

 

            newContact.contact_name = ccname;

            newContact.operator_id = redname;

            newContact.full_name = fname;

            newContact.email = email;

            var rc = newContact.doInsert();

                  if ( rc == RC_SUCCESS ){

                        print("user created and synchronized");

                        return newContact

                        }

                  else{

                        print( "Don't create the user " RCtoString( rc ) );

                        return null

                  }

            }

}

 

Tags: