cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Button to Set Field Value (JS)

Jump to solution

Hi All,

I am very new to JS.

I want a series of buttons, when one of them is clicked, it will write a certain value to a text field hidden on my form.

I have given my single line text box a JS ID, called "TabRules".

On button1, I have set client click to "Tab1Function()"

Now I need help writing that function!

I tried this but no luck:

function Tab1Function () {

NWF$("Tab1").click();

document.getElementById("TabRules").value = "My value";

}

Tags (1)
Reply
5 Replies
Workflow Hero

Re: Button to Set Field Value (JS)

Jump to solution

Hello Dave Georgopoulis​ you're close! Here's a few updates to your scripts that should get you working!

Custom JavaScript in Form Settings:

function Tab1Function () {

  NWF$('#' + TabRules).val("My value");

}

JavaScript within your custom button's Client Click property:

NWF$(document).ready(function(){

    Tab1Function();

});

A few Notes:

  • Since you're already calling the Tab1Function() within your button's client click property, this doesn't need to be a part of the function itself (removed this piece).
  • I also did a little clean-up inside your function and used a jQuery approach to assigning your new "my value."

Good luck!

Reply
Workflow Hero

Re: Button to Set Field Value (JS)

Jump to solution

Wow! Thank you so much Patrick!

I can't believe I was "close" but I appreciate the encouragement!

The writing to the field is working perfectly!

Now I just have to figure out why rules won't fire!

thanks again

0 Kudos
Reply
Workflow Hero

Re: Button to Set Field Value (JS)

Jump to solution

No problem Dave Georgopoulis​ – happy to help!

Reply
Workflow Hero

Re: Button to Set Field Value (JS)

Jump to solution

How can we do the same to set a value on a SQL request control. which is rendered as Label.

0 Kudos
Reply
Workflow Hero

Re: Button to Set Field Value (JS)

Jump to solution

Hi Patrick,

I am wanting to do the same action with replacing a value, but I want to take a people picker field and set it to nothing. Is there a way to do this that you know of?

0 Kudos
Reply