Using getIds and updateRecord function, this snippet is fetching the phone numbers of all selected customers and storing it in a file
Last updated: 2023-11-16
Using getIds and updateRecord function, this snippet is fetching the phone numbers of all selected customers and storing it in a file
package com.temenos.t24;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import com.temenos.api.TStructure;
import com.temenos.t24.api.complex.eb.servicehook.ServiceData;
import com.temenos.t24.api.complex.eb.servicehook.SynchronousTransactionData;
import com.temenos.t24.api.complex.eb.servicehook.TransactionControl;
import com.temenos.t24.api.hook.system.ServiceLifecycle;
import com.temenos.t24.api.records.customer.CustomerRecord;
import com.temenos.t24.api.system.DataAccess;
/**
* @author Danish The Techie
*/
public class CustomerWorking extends ServiceLifecycle {
static int processed = 0;
@Override
public List<String> getIds(ServiceData serviceData, List<String> controlList) {
List<String> records = null;
DataAccess da = new DataAccess(this);
records = da.selectRecords("", "CUSTOMER", "", "WITH RESIDENCE EQ US ");
return records;
}
@Override
public void updateRecord(String id, ServiceData serviceData, String controlItem,
TransactionControl transactionControl, List<SynchronousTransactionData> transactionData,
List<TStructure> records) {
//storing customer id received as input params
String custId = id;
String fileName = "Customer-Contacts.csv";
DataAccess da = new DataAccess(this);
CustomerRecord cusRec = new CustomerRecord(da.getRecord("CUSTOMER", custId));
String mnemonic = cusRec.getMnemonic().getValue();
for(int i = 0; i<cusRec.getPhone1().size(); i++){
String phoneNum = cusRec.getPhone1(i).getPhone1().getValue();
String sms = cusRec.getPhone1(i).getSms1().getValue();
try {
File file = new File("../../bnk/UD/REPORTS.BP/"+fileName);
FileWriter fileWriter = new FileWriter(file, true);
fileWriter.append(custId + "|" + mnemonic + "|" + phoneNum + "|" + sms );
fileWriter.append("\n");
fileWriter.close();
processed++;
} catch (IOException e) {
e.getMessage();
}
}
}
}