We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

johnds
Posts: 5
Joined: Thu Dec 18, 2014 11:31 am

Custom Action parameters...

Hi again,

I understand that in AI, the Action Data allows you to pass 'parameters/data' to your custom action function.
This is in the format: <parametername>=<value>;<parametername>=<value>; This works great, until you have a data <value>
that itself contains ";", like an SQL Connection string for eg, which then just gets chopped up by AI.

How can I pass something like: connectionstring=[CONN_STR] where [CONN_STR] is a value that does contain ";" characters and that it does not get chopped up?

Thanks!
John.
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Custom Action parameters...

Hi John,

In general in the Action Data field you can format the parameters however you want, in the example from this article we use the pipe character ('|') as separator.

What custom action type are you using?

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
johnds
Posts: 5
Joined: Thu Dec 18, 2014 11:31 am

Re: Custom Action parameters...

Hi Bogdan,

I am using a "Call function from attached Native DLL" type, if that's what you are asking. :-)

That example you've posted is an example of expecting the function that is being called to actually perform tokenization of the input data. I was hoping to avoid having to do that.

Your answer does not seemed to have given me any clue as to whether or not a value that contains any ';' characters can be used without AI cropping the value after the very first ';' it finds.

John.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action parameters...

Hello John,

Unless your custom action is not an Installer class action, you can set and format the "Action Data" field as you need (there are no format requirements). The content of the above field will be resolved and set at install time in the "CustomActionData" property.

For instance, when using a "Call function from attached Native DLL" custom action type, you can set the "Action Data" field like this:

Code: Select all

connectionstring=[CONN_STR]|connectionstring2=[CONN_STR2]
and then, you should get the "CustomActionData" property value within your action code and parse it in order to extract the desired info from its content. Getting "CustomActionData" property value and its parsing operation should be done within your custom action code.

If you have any questions let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
johnds
Posts: 5
Joined: Thu Dec 18, 2014 11:31 am

Re: Custom Action parameters...

Thanks for the reply Daniel,

but it seems that nobody there is understanding the problem. Now, please, read carefully what I am saying...in AI, when you set the Action Data field in your UI to something like: connectionString=[CONN_STR],I don't care about multiple parameters! I only have one parameter, and if [CONN_STR] contains something like: "Data Source=(LocalDb)\v11.0;Initial Catalog=MyDB;Persist Security Info=True;", then, inside my custom action code (.net C#), if I do something like:

string connectionstring = session.CustomActionData["connectionString"];

connectionstring will be: "Data Source=(LocalDb)\v11.0" only!. Why? Well, because it seems that the ";" character is being processed during the phase where the values are being inserted into the session.CustomActionData array object, and the string value (in my case, whatever is inside the [CONN_STR] variable) is being stripped/truncated after the first ';' character.

The only way I see that this would work, is if in the Action Data field in AI, I don't use ';', but something else (like '|' maybe), and then in my code, I parse and replace '|' for ';' (which is needed for SQL connection strings to work).
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Custom Action parameters...

Hello John,

I apologize for the confusion. Now I think I completely understood your scenario. Indeed, this happens because you are trying to directly access an explicit parameter (i.e. connectionString) set in the "CustomActionData" property. Indeed, when a parameter value include the ; semicolon character, then its value will be truncated. However, this behavior it is not influenced by Advanced Installer, but the "session" object. All that Advanced Installer does is to set the "CustomActionData" property value with the string set in the "Action Data" field of your custom action.

It seems, when using a C# custom action, to escape the ; character within a parameter value (set in the "CustomActionData" property) you should duplicate it. For example, you can set the "Action Data" field of your custom action like this:

Code: Select all

connectionstring=UID=user1;;PWD=pass1;;;connectionstring2=UID=user2;;PWD=pass2;;
and then access within your C# action code the "connectionstring" and "connectionstring2" parameters like this:

Code: Select all

string param1 = session.CustomActionData["connectionstring"];

string param2 = session.CustomActionData["connectionstring2"];
Also, as another solution you can use a C# statement like this:

Code: Select all

string custom_action_data_value = session["CustomActionData"];
to access the entire value of the "CustomActionData" property, and then parse the "custom_action_data_value" string in your custom action code and process it as you need.

If you have any questions just let us know.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”