Question Ronaldo Nascimento · Jul 9, 2025

How can I get the value of a submit button (ie the name on the button) from a CSP Object?

I am trying to get the value of a Submit button on a CSP object page.

<input type="Submit" value="Assign" name="action" id="action">

I tried getting it thru $GET(%Request.Data("action")), but it throws an Undefined error. Isnt $GET supposed to handle it if its undefined anyway?

How do I get the "value" of the button pushed when the form is set to POST?

Product version: IRIS 2024.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2024.1.2 (Build 398_0_23819) Wed Nov 20 2024 18:24:21 EST

Comments

Yaron Munz · Jul 9, 2025

try $GET(%Request.Data("action",1))
Don't forget that you need to have the <input...> in a <form...> ... </form>

0
Ronaldo Nascimento  Jul 9, 2025 to Yaron Munz

My bad I forgot to add the ,1 in the Data method. It still crashes and gets an Undefined error.

Set action = $Get(%Request.Data("action", 1), "")
0
Yaron Munz  Jul 9, 2025 to Ronaldo Nascimento

add a debug to OnPreHTTP and check the ^%global
k ^%global S a="" F  s a=$O(%request.Data("")) Q:a=""  m ^%global(a)=%request.Data(a)

sometimes, better to check: $D(%request.Data("action",1)) and not $G

0
Ronaldo Nascimento  Jul 9, 2025 to Yaron Munz

$D(%request.Data("action",1)) worked, I was able to determine which of the submit buttons was pressed. Thank you!

0
David Hockenbroch · Jul 9, 2025

Ronald, if that's your exact code, it may be because you have it as %Request instead of %request, lowercase r. Because %Request is undefined, it can't tell you whether %Request.Data("action",1) is undefined or not. Try it with %request.

0