Hi ma,
thanks for your answer.
To all who suffer under the same problem:
I finally found a way to retrieve the data i needed.
Thx to the almighty ScriptHelper-Object
First i had to add the Mailing-ID to the unsub-link:
Code: Select all
http://myopenemmserver.com:8080/form.do?agnCI=1&agnFN=my_unsub_form&agnUID=##AGNUID##&mi=##MAILING_ID##
Note the appended mi-Parameter, it will be used in the script below!
Then I've created an action, used as initial action for my
unsub-form, consisting of two steps:
1. Load recipient-data
Load even if customer is not a active subscriber (not checked)
2. Script-Action
Code: Select all
## Set company-ID (could also be retrieved from requestParameters)
#set( $company_id = 1 )
## Get the mailing-ID which we set in the mailings unsubscribe URL
#set( $mail_id = $requestParameters.mi )
#if( $mail_id )
## Requestparameters seem to be strings, so we need an integer for casting
#set( $Integer = 0 )
#set( $mail_id_int = $Integer.parseInt($mail_id) )
#if( $mail_id_int )
## Using the MailingDao we instantiate a mailingbean
#set( $mailing = $MailingDao.getMailing($mail_id_int, $company_id) )
#if( $mailing )
## Now we can retrieve the mailinglist-ID
#set( $mail_list_id = $mailing.getMailinglistID() )
#if( $mail_list_id )
## Using the ScriptHelper-object, we instantiate an ApplicationContext-object
#set( $app_context = $ScriptHelper.getApplicationContext() )
#if( $app_context )
## With it we can instantiate (any Bean/Dao, especially a) mailinglistbean
#set( $mailing_list = $app_context.getBean("MailinglistDao").getMailinglist($mail_list_id, $company_id) )
#if( $mailing_list )
## Finally we can retrieve the shortname of the mailing_list
#set( $mailing_list_name = $mailing_list.getShortname() )
#end
#end
#end
#end
#end
#end
## This seems to be mandatory for a script not to result in an error
#set( $scriptResult="1" )
Now i can use the Mailinglist-Name in the unsub form:
Code: Select all
Click below to unsub from Mailinglist <strong>$!mailing_list_name</strong>!
The big (and ugly) if-triangle in combination with
quiet reference (the ! in front of 'mailing_list_name'-variable) make sure,
that the mailing_list_name will only appear, if a mi-Parameter is passed via
unsub-URL:
I.E.
http://myopenemmserver.com:8080/form.do ... gnUID&mi=5
will -assumed Mailinglist "FancyStuff4U" has ID 5- result in
Click below to unsub from Mailinglist FancyStuff4U!
http://myopenemmserver.com:8080/form.do ... someAgnUID
will result in
Click below to unsub from Mailinglist !
http://myopenemmserver.com:8080/form.do ... &mi=foobar
will result in the error template.
I hope, my solution-post can help other OpenEMM-Users.
Have Fun and happy OpenEMM'ing
-diax