application.getStartupArguments

Hi

I am not certain this function is working as described in the manual. As I understand it this function should return any arguments passed via the URL to a web client in the form of and array. I would therefore expect to get an array returned and be able to split this using the format array[0] for the first item etc

I have done a simple test site which can be accessed at the following address

http://clipper.clickdigital.com/servoy- … est2|Test3

Note I would expect this code to return an item in each of the boxes using this function:

function startup2() {
var args_array = application.getStartupArguments();
forms.login.Arg1 = args_array[0];
forms.login.Arg2 = args_array[1];
forms.login.Arg3 = args_array[2];
forms.login.arguments_array = args_array;
forms.login.arguments_array_length = args_array.length;
}

ie that args_array would now be an array

The results I am trying to obtain can be seen with this:

function startup1() {
var args_array = [‘Arg1’,‘Arg2’,‘Arg3’];
forms.login.Arg1 = args_array[0];
forms.login.Arg2 = args_array[1];
forms.login.Arg3 = args_array[2];
forms.login.arguments_array = args_array;
forms.login.arguments_array_length = args_array.length;
}

Having spent some time fiddling about with this any pointers to obvious errors would be appreciated

best
gordon

Hi Gordon,

if I’m not mistaken, the webclient gets the arguments as a string,
the smart client however as an array.

So if your solution should handle both, you should test which client is being used.

Hope this helps!

Hi Marc

Although strange that makes sense based on the response I am getting from the web client. The docs suggest its all passed as an array and I would wonder why Servoy would have changed the approach - array seems a lot easier for all concerned !!

Thanks for the reply

best
Gordon

We’ve been using both web and smart client since v3.5. It’s always been like this.
It will be very unlikely to change.

Anyway, if you just pass your arguments with a separator you know (I believe you now use ‘|’), your code can look something like this:

function startup1()
{
var args_array = ('' + application.getStartupArguments()).split('|');
forms.login.Arg1 = args_array[0]
etc.
etc.
}

starting from version 5, getStartupArguments can return null,
if no arguments are used, or an array with 2 elements : the first
element is the value of the ‘argument’ used in the startup link,
and the second element is a javascript object containing all the
startup arguments identified by names

in case of your url:
http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/Test1|Test2|Test3
var startup_args = application.getStartupArguments();
var argument = startup_args[0]; // it is ‘Test1|Test2|Test3’
var starup_args_object = startup_args[1]; // startup_args_object.a is also ‘Test1|Test2|Test3’

you can pass multiple named arguments using an url of this form:
http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/defaultArgumentValue/argName1/argValue1/argName2/argValue2
var startup_args = application.getStartupArguments();
var argument = startup_args[0]; // it is ‘defaultArgumentValue’
var starup_args_object = startup_args[1]; // startup_args_object.a is also ‘defaultArgumentValue’, startup_args_object.argName1 is ‘argValue1’, startup_args_object.argName2 is ‘argValue2’

Hi Gabi

Thanks for this - it makes sense and explains the object in argument 2 that was being returned

This whole revisit of the arguments started with the intention of using Servoy to listen for IPN returns from Paypal. They send a string in the form Pay, Send and Save Money with PayPal | PayPal US - I concluded that it was therefore not possible to get Servoy to listen for this response and have instead used a PHP listner and had it pass the details to Servoy as it prefers ie your suggested format.

Best
Gordon

Please note:

using application.getStartupArguments() do not always return the correct arguments.
This occurs whenever you have an active session already.
for Mac users this is real easy as Safari doesn’t close by default, windows users experience this for example clicking a 2nd link when there’s already a webclient connected in another tab of your browser.

Anyway when using something like this: ‘http://clipper.clickdigital.com/servoy-webclient/ss/s/TestArgs/m/startup2/a/Test1|Test2|Test3

You’d better ask for the arguments like this:
var startup_args = arguments;

This way you always get the correct arguments into your var.
This ONLY works when having a method specified in the link (‘/m/startup2/’)

All credits to Paul Bakker who helped me out on this yesterday.

Hi all,

I would to pass a number as argument and following the Marc example I’ve tried with:

http://localhost:9090/servoy-webclient/solutions/solution/file_solution|877

and with:

http://localhost:9090/servoy-webclient/solutions/solution/file_solution?var1=877

but without result.

Can you tell me the correct way to pass an argument to a servoy web application?

thanks in advace

Marco

Marco R.:
http://localhost:9090/servoy-webclient/solutions/solution/file_solution|877

You might like to try this

http://localhost:9090/servoy-webclient/ss/s/file_solution/m/yourstartupmethod/a/877

ss/s are a shortcut for solutions/solution that makes the URL easier to read
a = arguments ? wont work with Servoy
m = the method that receives the arguments and this needs to be a global

HTH
Gordon

Clear gordon.

Thanks for your time :)

Marco

Hi,

When I am trying to call a global method in my Web Solution using the below URL the argument I send to the function is not received by the method.
example of URL :- “http://localhost:8080/servoy-webclient/solutions/solution/MySolution/method/SomeMethod/arguments/001

the function defination :-
/**

  • @param {String} arg
  • @properties={typeid:24,uuid:“BAF06510-68E4-4A2D-8D56-803F4FE0CA66”}
    */
    function SomeMethod(arg)
    {
    application.output('Success :- '+ arg);
    }

but arguments was not received by the global method in the solution. It was displaying the message as Success :- undefined.
I don’t know were am going wrong please help me out…???

Found the answer for the above… :)
used argument instead of arguments in the URL to pass the parameter.

The short version of of the URL makes this a lot easier i.e. the ss/s and m and a - especially in my case where I am dreadful at spelling :roll:

http://localhost:9090/servoy-webclient/ss/s/file_solution/m/yourstartupmethod/a/877