sc_redir passing and receiving parameter

How do I passing parameter from “Form A” to “Form B”, And after selecting a field from “Form B”, return the value back to “Form A” using sc_redir (or other commands). Similar to “Retrieve data from grid” but need to be called from with php code.

  1. In “Form A”, after on_blur event of a field, I like to call “Form B”
  2. In “Form B”, I like to have “Select” button in front of each row.
  3. After clicking “Select” button in “Form B”, I like the value of first field in that row to be returned and use in 2nd field of “Form A”
  4. Similar to “Retrieve data from grid” but “Retrieve data from grid”, I have to click an icon on the side of that field. I like the app to automatically call “Form B” after pressing Enter without clicking an icon.

Please help.

[QUOTE=capecode;24571]How do I passing parameter from “Form A” to “Form B”, And after selecting a field from “Form B”, return the value back to “Form A” using sc_redir (or other commands). Similar to “Retrieve data from grid” but need to be called from with php code.

  1. In “Form A”, after on_blur event of a field, I like to call “Form B”
  2. In “Form B”, I like to have “Select” button in front of each row.
  3. After clicking “Select” button in “Form B”, I like the value of first field in that row to be returned and use in 2nd field of “Form A”
  4. Similar to “Retrieve data from grid” but “Retrieve data from grid”, I have to click an icon on the side of that field. I like the app to automatically call “Form B” after pressing Enter without clicking an icon.

Please help.[/QUOTE]

1.If you call another application using sc_redir then passing variables will be done inside this routine. Suppose you need to pass a field:

sc_redir(myapp.php,myglobal={myfield},’_parent’).

The variable put in the sc_redir will become a global variable in your called application.

2.In grids you can add an image as a custom field and apply a link to that to get a ‘custom icon’.

3.That depends on your link, but you can only return one variable.

  1. Don’t understand that question. But if you need to apply something on enter you need to add custom javascript. In general this will not be easy to do in SC afaik.

Aducom, what he sais is a Capture link but by code

That would be hard to make. Only way I can think of is an application link.

Yes, I meant Capture Link but called from php code.
Would it be possible to implement it?

Aducom, when you say an application link, please explain a little bit more. I will need the value from “Grid B” to be passed back to “Form A” too.

Thanks.

In general you use global variables to pass variables from one app to another, even if you have a return value. If you do it using sc_redir you need to pass them as parameters in this macro. Otherwise you can just use the bracket variables.

Thanks Aducom for your advise. I tried passing parameters from sc_redir but I am unable to get “Grid B” to show “Select” button in front of each row (as in capture field link). Any ideas?

Further update to my post, this is what I have tried

  1. From “Form A”, I used sc_redir (“Grid B”, [glo_var], modal)
  2. “Grid B” shows up and I add OnClick Event to the first field of “Grid B”. In OnClick Event, I tried to assign [glo_var] = {GridB_Field1}. But apparently, this does not work (cannot assign value, don’t know why).
  3. Again on Grid B, I change OnClick Event to call php method “AssignValue” and in Php method, I created “AssignValue” and put [glo_var] = {GridB_Field1}. This still doesn’t work.
  4. Agian, I added an application link to “Field1” of “Grid B” and point it back to “Form A”. After click Field 1 on Grid B, the app return back to “Form A” but I cannot get the value of “Field1 - Grid B” back.

Any ideas or suggestion on how to assign value of “Field1” of “Grid B” back to “Form A”?

The only way afaik I know of to get a button in a grid is by adding it as a image field manually to the grid. But other point will be that you need to add custom php code to the event and you will only be able to create a link to the original application. I’m thinking of other solutions like applying a hyperlink to it calling a blank application, but I’m affraid I don’t have a straight and good answer.

Look at sc_master_value() …

Indeed! tnx. Rheinhart, overlooked that one.

Thanks. I’ll give it a try.

Just an update. I just couldn’t seem to find a way to return the value back even with sc_master_value(). I don’t know what I did wrong but the code flow seems to stop in a php method where sc_master_value is present. When comment out sc_master_value, the code flows all the way.

Maybe don’t works if it’s not a master/detail relationship

I saw all above and think it’s not sc_master_value’s thing.

If it’s not a master/slave, the sc_master_value cannot work, and the capture link will not work if you want to fetch more than one result(such as you return a string separated with";", and resolve the string by yourself.).

I want to refresh the data of FormA after calling FormB, and to make it use for Scriptcase, save the FormB/GridB’s result to tmp table.

And call like this cannot work either:

btnCall’s OnClick:
sc_redir(gridb, modal);
{lblInfo} = Value fetched from table;

It’s seems when sc_redir is called, the after code cannot execute.

That’s right and very logical. sc_redir does - as the name says - a redir, it handles the control over to another php application. It’s not a call to a procedure. This is standard php and the real thing would be to use global variables like:

sc_redir(gridb,returnto=myapp.php);

in your called application (not modal, I haven’t tested that)

sc_redir([returnto], retrieved={myvalue});

Since all Scriptcase apps are based on database, I’m finish this like:

  1. Before sc_redir, create a key(like a GUID) and pass that key to the sc_redir as a parameter;
  2. On the redired page, write to a table with a key passed in (that GUID);
  3. After return to the origin page, search the table with the key(that GUID) and do the next step;

That’s my solution.

To avoid data garbage you can consider using a temporary table. Personally I would go for my option as you can serialize an array of data into a single variable.

I was hopping to find my answer here based upon the question. Please advise:
I have the following that calls an SMS API, which returns a Result either 1 (successful) or -1 (unsuccessful).

sc_redir(https://abc.com/trigger_sms.php?phone=$phone&msg=$message,"","");

How do I get the result into a variable please?

This is not the way to go. sc_redir will pass control to another url, it is not a function call. A right way might be:

$myresultg = file_get_contents(“https://abc.com/trigger_sms.php?phone=$phone&msg=$message,’’,’’”);