I wanted to simplify a bit profile update implemented in OpenEMM, basically I don't want to add new columns in database each time I want to track users' clicks.
That's why I'm trying to implement general action that would update user's profile once he clicks on a link.
Let's say the field is called "clicks" and is anchored to all buttons in all mailings. If user clicks on any link in newsletter than script adds string " <date> <mailing number> <button> |".
So, for example if user clicked 3 times in 3 separate mailings (with IDs 3,5 and 7) than field "clicks" would have following data "2013-03-03 3 BTN3 | 2013-03-20 5 BTN2 | 2013-04-02 7 BTN8 |"
So far, in my action, I'm trying to read user data, modify any field and save it back to database. Below action loads user's profile and tries to modify field "lastname".
Code: Select all
$ScriptHelper.println("---------------START----------------")
$Customer.resetCustParameters()
$Customer.setCustomerID($customerID)
$Customer.setCompanyID(1)
$Customer.loadCustDBStructure()
$Customer.loadAllBindings()
#set($requestParameters=$Customer.getCustomerDataFromDb())
$ScriptHelper.println($requestParameters.lastname.toString())
$requestParameters.put("lastname", "MODIFIED LASTNAME")
$ScriptHelper.println($requestParameters.lastname.toString())
#if($Customer.importRequestParameters($requestParameters, null))
$ScriptHelper.println("requestParameters SUCCESS")
#else
$ScriptHelper.println("requestParameters FALSE")
#end
$ScriptHelper.println("$CustomerID | $CompanyID | $requestParameters")
#if($Customer.updateInDB())
$ScriptHelper.println("Customer update SUCCESS")
$ScriptHelper.println($Customer.lastname.toString())
#else
$ScriptHelper.println("Customer update FALSE")
$ScriptHelper.println($Customer.getCustomerDataFromDb().lastname)
#end
$ScriptHelper.println($Customer.getCustomerDataFromDb().lastname)
$ScriptHelper.println("-----END------")
#set($scriptResult="1")
In documentation, for method $Customer.updateInDB() it's written "Set the following parameters before calling this method: CustomerID, CompanyID (EMM only) and import $requestParameters"
and I think I did set them properly.
Here is what I get in openemm_core.log:
Code: Select all
2013-04-03 10:05:50,098: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - ---------------START----------------
2013-04-03 10:05:50,126: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - OldName
2013-04-03 10:05:50,126: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - MODIFIED LASTNAME
2013-04-03 10:05:50,127: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - requestParameters SUCCESS
2013-04-03 10:05:50,127: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - 46697 | 1 | {lastname=MODIFIED LASTNAME, creation_date_second_date=37, change_date_day_date=2, creation_date=2013-03-27 18:08:37, title=, change_date_minute_date=23, creation_date_month_date=3, creation_date_day_date=27, change_date_second_date=58, creation_date_hour_date=18, creation_date_year_date=2013, change_date=2013-04-02 10:23:58, firstname=Tom, change_date_year_date=2013, change_date_hour_date=10, datasource_id=12, mailtype=1, email=email@company.com, creation_date_minute_date=8, change_date_month_date=4, customer_id=46697}
2013-04-03 10:05:50,127: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - Customer update SUCCESS
2013-04-03 10:05:50,127: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - MODIFIED LASTNAME
2013-04-03 10:05:50,129: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - OldName
2013-04-03 10:05:50,129: ERROR [http-8080-11] org.agnitas.util.ScriptHelper - -----END------