You are viewing limited content. For full access, please sign in.

Question

Question

Select radio button option based on whether user is anonymous or authenticated

asked on December 30, 2025

Is it possible to select a radio button based on user authentication? If the user comes in through the public portal and is not authenticated ("anonymous") I want to select Radio Button 'A'. If the user is not "anonymous" I want the form to default to Radio Button 'B'.

This is in the Modern forms designer.

0 0

Answer

SELECTED ANSWER
replied on December 30, 2025

I can think of two ways to do this. Not sure if they're the best options, but they work :)

 

Create a Single Line field and set the default value to the current user name. You can use a Field Rule to hide it and save the value if you don't want the Submitter to see it.

Set the Radio Button default to 'B' (my example has 'Logged In User'). Then add this JavaScript to change it if the submitter is Anonymous.

var formStartedBy = LFForm.getFieldValues({fieldId: 70});
    
if (formStartedBy === 'Anonymous User') {
  LFForm.setFieldValues({fieldId: 107}, {value: "Anonymous User"});
}

Alternatively, if you don't want to set a default value for the Radio Button, you can use this JavaScript.

var formStartedBy = LFForm.getFieldValues({fieldId: 70});
    
if (formStartedBy === 'Anonymous User') {
  LFForm.setFieldValues({fieldId: 107}, {value: "Anonymous User"});
} else {
  LFForm.setFieldValues({fieldId: 107}, {value: "Logged In User"});
}

2 0
replied on December 30, 2025

That works nicely - thanks!

 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.