CG0129inz - FÆRGEN A/S Kundepanel - Import email info to base questionnaire

From Catglobe Wiki
Jump to: navigation, search

General information



Site
inzights.catglobe.com
Catinét project no
0129inz
Client

How to send out reminders

Goal

This is a standard setup to import the file which contains the email address to the base questionnaire then send the invitation to the imported email.

How to do

The general solution is to execute the .exe program to upload the csv file. After it is uploaded, the workflow script will validate and import the uploaded info to the base questionnaire.

Step 1 : Create the list of email address

We create the ".csv" file containing the email address like

File containing the email address.jpg

Step 2 :Prepare the workflow script for solving the uploaded data

array a = Workflow_getParameters();
string csvData = a[0];
number importtype = convertToNumber(a[1]);
number DCSRid = 1497858; // DCS : used for filtering the email. The real value should be : 1497858
number PQRid = 1289245; // PQRid: used for the imported PQ. The real value should be :  1289245
number MailtemplateRid = 1497895; // MailtemplateRid: used for the mail template. The real value should be :  1497895
DCS_use(DCSRid); 
DCS_rebuild();

number InvitationBmRid = 0;
number  info_wfrid = 1293521; //CG0129inz - FÆRGEN A/S Kundepanel - get info from the record on csv file
number  Creategroup_wfrid = 1308275; //CG0129inz - FÆRGEN A/S Kundepanel - Create group of recipients
number validate_info_wfrid = 1497863; //CG0129inz - FÆRGEN A/S Kundepanel - Validate the email csv info
//number optimize_wfRid = 1497864; //CG0129inz - FÆRGEN A/S Kundepanel - Optimize the email csv record
number optimize_wfRid = 1605713; //CG0129inz - FÆRGEN A/S Kundepanel - Optimize the email csv record - ver 2
number createQAS_wfRid= 1497865; //CG0129inz - FÆRGEN A/S Kundepanel - create qas n base qnaire
number import_wfRid= 1497867; //CG0129inz - FÆRGEN A/S Kundepanel - Import email data
number Bulkmail_wfRid = 1541304; // CG0129inz - FÆRGEN A/S Kundepanel - Do the mailout for recipients

// Create the new groups containing the respondent
number groupTemplateResourceId = 773261; // standard group
number parentResourceId =  1297798; // CG0129inz- Færgen KundeForum - group import
number EmailgroupRid = Workflow_call(Creategroup_wfrid, {"CG0129inz - Færgen KundeForum - Import email to Base qnaire", parentResourceId , groupTemplateResourceId }); 

array currentdatetime = getCurrentDateTime(Timezone_Romance_Standard_Time);
number currentvalue = currentdatetime[DateTime_Year]*10000 + currentdatetime[DateTime_Month]*100 + currentdatetime[DateTime_Day];

//start get the upload csv file
string empt = empty;
CsvReader csv = new CsvReader(csvData, true, ";", "'", "\"", empt, true, false);
number fieldCount = csv.FieldCount;
array addToSurvey;
array headers = csv.Headers;
while(csv.ReadNextRecord()) {
Dictionary csvinfo = Workflow_call(info_wfrid, {fieldCount, headers, csv});
if (Workflow_call(validate_info_wfrid, {csvinfo,DCSRid})== true)
 {
	  addToSurvey.Add(csvinfo);
 }
}
//addJournal(1497860,54,"Comment","before optimize_wfRid " + convertToString(addToSurvey));
if (isEmpty(addToSurvey) == false) 
{
	//Remove the duplicate email
	addToSurvey = Workflow_call(optimize_wfRid,{addToSurvey});
	
	//create qas and import		
	addToSurvey  = Workflow_call(createQAS_wfRid,{PQRid,EmailgroupRid,addToSurvey});
	Workflow_call(import_wfRid,{addToSurvey,PQRid,importtype});
	//send bulkmail
	InvitationBmRid  = Workflow_call(Bulkmail_wfRid,{"CG0129inz - Færgen KundeForum - Email Import To Base Qnaire Invitation",PQRid,MailtemplateRid,EmailgroupRid});	

}		
addJournal(1497860,54,"Comment","Import for " + convertToString(currentvalue) + " is done. The bulkmailRid "+ convertToString(InvitationBmRid) + " was sent out.");

Step 3 : Execute the program to upload the file

Open the command line, then Execute "SendFileToCatglobe.exe". This program will need the params like below :

  • username : input the username for logging to the site where we input the workflow
  • password : input the password for logging to the site where we input the workflow
  • workflowrid : input the workflow resource id which we will execute when the file is uploaded
  • url : the site URL where we input the workflow
  • filename : the name of imported file. As usually, I always put the file in the same location with the program.
  • import type : currently, we only support 2 types : "email" (value = 6) and "Aftale kunde" (value = 7)

Here is example :

The program executed.jpg