redirect from grid to form

Hello.

I would like to do this:
I have some fields in a grid and I would make sure that if, let’s say a field field1 == ‘YES’
clicking on it does a redirect towards a certain “form_target.php” in which I have set two global variables [glo_id1] e [glo_id2].

In practice should take id1 and id2 from the grid records and use them to do the redirect towards the form.

I tried with an ajax event onclick like this:

if({field1} == ‘YES’) {
sc_ajax_message("Go to form, “Handle data”, “modal=Y&button=Y&button_label=OK&width=420&redir=form_target.php&redir_target=modal”, “glo_id1={id1};glo_id2={id2}”);

but it does not work.

maybe something must be done on the onrecord events…i don’t know

The grid is already linked to another form so I can not take advantage of the standard SC option from Links–>application

also i have a couple of these fields from where i need to do a redirect towards different forms.
In other words i need a method to make a field clickable (if==yes) that triggers a redirect.

Is it possible?
Thanks

Maybe you want a field link? LINKS > NEW LINK > FIELD > Choose your field > choose the form that will open. Then (in the target form) write your code in events.

don’t think this works.

it only makes me buil field link towards other grids, i need to redirect towards a form
Thanks

You can link to forms, but you can’t condition it.
Best bet I think is to use onRecord event, make your condition and use sc_link macro

sc_link(Column, Application, Parameters, "Hint", "Target", Height, Width) [TABLE="class: macros_desc_table"]
 	 		[TR]
 			[TD] 			This macro dynamically creates or modifies links between grid applications and other applications.
			 
  			[B]Column[/B]: Grid column field name to generate the link.
			[B]Application[/B]: Application name to establish the link.
			[B]Parameters[/B]: Parameters required by the called application.
			
			Must be informed "=" (attribution sign) . More than one parameter must be separated by ";" (semicolon).
			
			[B]Hint[/B]: Observation or tip displayed when the mouse cursor passes over the link.
  			[B]Target[/B] : Where the application will function call and may be:
  			[TABLE="border: 0"]
 				 					[TR]
 						[TD="width: 15%, align: left"][B]Target[/B][/TD]
 						[TD="align: left"][B]Descri??o[/B][/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"_self"[/TD]
 						[TD="class: corpo1, align: left"]For carrying on the same page (overrides the query);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"_blank"[/TD]
 						[TD="class: corpo1, align: left"]To run on another page (pop-up);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"iframeT"[/TD]
 						[TD="class: corpo1, align: left"]To run in an iframe above the Grid (top);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"iframeL"[/TD]
 						[TD="class: corpo1, align: left"]To run in an iframe, the left of the Grid (Left);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"iframeR"[/TD]
 						[TD="class: corpo1, align: left"]To run in an iframe, the left of the Grid (Left);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"iframeB"[/TD]
 						[TD="class: corpo1, align: left"]To run in an iframe below the Grid (Bot);[/TD]
 					[/TR]
 					[TR]
 						[TD="class: corpo1, align: left"]"modal"[/TD]
 						[TD="class: corpo1, align: left"]Opens a new window and blocks any interaction in the main window;[/TD]
 					[/TR]
 				 			[/TABLE]
  			In the case of modal target, there are two optional parameters *:
  			[B]*Height:[/B] Set the height of the modal window (default 440);
			[B]*Width:[/B] Set the width of the modal window (default 630);
			 
  			[B]Note:[/B] If omitted, will be assigned the value "_self".
  			 
  			[B]Ex. 1:[/B] [B]Creates a link to the costumer.php application, on the [/B][B]Id field, passing the [/B][B]global variable [global_costumer] as and the [/B][B]product field (local variable) {Id} to the [/B][B]costumer.php application:[/B]
			sc_link(Id, costumer.php, product=[global_costumer]; Id={Id}, "Client Data", "_blank");
  			
			
			[B]Ex. 2:[/B] [B]Creating a dynamic link to another application depeding on the field valor {costumer_type} and opening it in a modal.[/B]
			if ({costumer_type} == "F") {
			sc_link (costumer_type, type_f.php, product=[global_costumer]; Id={Id}," Personal Data ", "modal", 500, 700);
			}
			else{
			sc_link (costumer_type, type_a.php, product=[global_costumer]; Id={Id}," Company Data ", "iframeR");
			}
  			
			[B]Ex. 3:[/B] [B]Creating a link to an URL: in this case, "paramater and target" have no effect. It will be executed redirecting to a informed URL.[/B]
			sc_link (my_field, http://www.scriptcase.com, ,"hint of the link");
 			[/TD]
 		[/TR]
 	 [/TABLE]
    [B]Macro Scope[/B]
  [TABLE="class: macros_desc_scope_table, cellpadding: 0, cellspacing: 0"]
 	 		[TR]
 			[TD]Grid application[/TD]
 			[TD]ReportPDF application[/TD]
 		[/TR]
 		[TR]
 			[TD="width: 120px, bgcolor: #f7f4f4"]onRecord[/TD]
 			[TD="width: 120px, bgcolor: #f7f4f4"]onRecord[/TD]
 		[/TR]
 	 [/TABLE]
 

Thanks i’ll take it a look

sorry but maybe it’s me, but the manual is a bit confusing to me.
in the grid i have these three ids

id1 id2 id3 that i have to pass to the form target where i have set two global variables for the id1 and id2:

glo_id1, glo_id2,

and in the target form i have also the id3 not set as a global variable.

Now, then in the onrecord event of the grid i have set this:

if ({my_field_in_the_grid} == “yes”) {
sc_link (my_field_in_the_grid, target_form.php, [glo_id1]=id1; [glo_id2]=id2; {id3}=id3, " Hint text ", “_blank”);
}

Doesn’t work, i am doing sometnig wrong

Thanks