Sc_redir to other app with target link coming from a var

Hello experts, i face a trouble to link a control form to another control.
The problem is that in my case the first parameter of sc_redir macro is not a constant but a var coming from a table.
With this sql, i get the name off the app.
$sql=“select app from tests where idtests=”.{test};
sc_lookup(Dataset,$sql);
$test={Dataset}[0][0];
If i code this
sc_redir($test,IDFICHIERS_AVOIR=$id);
The link produce is :
The requested URL /scriptcase/app/fec/1/1.php was not found on this server.

If a code this, it is correct :
if ($test==“control2”)
sc_redir(control2,IDFICHIERS_AVOIR=$id);

then if I code :
sc_redir($test,IDFICHIERS_AVOIR=$id); FAILED !!

So, it seems that in case of internal app redir, the first parameter is only a constant.

Have you alredy seen this kind of case ? Have you succeed to find a workaround ?

Try this … How to create two more tabs from the grid

Try this.
[formname]=$test;
sc_redir([formname],IDFICHIERS_AVOIR=$id)
Good luck.

Jonathan

Sorry, but this is the same. It doesn’t work.

Try this.
$test = “control_tools”;
[form]=array($test);
sc_redir([form][0]);

or

$test = “…/control_tools”;
$a=array($test);
sc_redir($a);

both works in my test. Interesting.

Thank you for your help.
It’s quite strange !
It doesn’t work in my case.
Perhaps, cause of it’s an internal application and not a php script.
I add a copy screen to help you to see the trouble.
Many thanks Jonathan.

I saw your page.
Don’t forget add “…/” before your var.
Try it, Good luck.
Jonathan

Both syntax, don’t work in my case.
Here are with comments the differents syntax i tested in my code.

If you want to use a Variable in sc_redir macro for the application you must write it so
sc_redir(’’.$YourVariable.’’);
you have to put an empty string before and after the variable.

I know it’s strange but it works.

3 Likes

:clap:
Many thanks.
It’s working very well.
I don’t know how you found this !
Scriptcase !!! The best tool ! but with this kind of magical and strange behaviour !

Wow, You are wonderful! Good to know.

This needs to be in quotes. Even if you use sc_redir(’$YourVariable’); will work. The only thing i found is you cant use the variables for parameters. That sometime works and many times does not work.

When you look the code how it is processed from scriptcase in an php editor like phpStorm then you can find out if it helps to set the parameters in quotes or not, thats the only way to see how your code is processed by scriptcase and sometimes ist helps and sometime not.

One thing is also important, scriptcase has sometimes problems with Variables with upper case characters, so try to use only lower case characters in variables. So dont use $Variable use $variable instead this sometimes does the magic.

Thank you very much to these advices.
I really appreciate your help.