2

I have a html link which opens a Smartsheet form in new window so our online customers can fill out the form.

I would like to pass the value of a TextField (product name or product code) in my existing form to my smartsheet form. This would help my customers as they would not have to write the product name or product code a second time.

I have the following javascript to generate the URL that links to the Smartsheet form.

<script type="text/javascript">// <![CDATA[
var productName="productName.firstChild.nodeValue";
var sampleLink= "Order Sample!";
document.write(sampleLink.link("https://app.smartsheet.com/b/form?EQBCT=fbab5300a6d74cc58ae6326e267b3c4f/label.clsCaptionBold.clsFieldLabel/79019814="+productName));
// ]]></script>

The HTML code for the TextField is below:

<div class="clsField clsTextField"><label onclick="" class="clsCaptionBold clsFieldLabel" for="79019814">Product Name</label><br>
<input type="text" id="79019814" name="79019814" maxlength="4000" value=""></div>

I don't know if my javascript code is correct but when I click the link in the page I get the following message:

the form you are attempting to access is no longer active

What is the correct way to send data to a Smartsheet form?

Brett
  • 2,502
  • 19
  • 30
user3264403
  • 23
  • 1
  • 4

1 Answers1

1

Can I auto populate form data in a Smartsheet form?

Yes! :-)

How do I populate the form data in a Smartsheet form?

Option 1: Set a default value in the form

If the form data is always the same you can set a default value in Smartsheet's form editor. The screenshot below gives an example of this by setting the default value to 1 for the quantity.

default Smartsheet form value via form editor

Option 2: Pass a value in the link

A default value can be sent to the form by modifying the link and passing the value in the URL. This can be accomplished by using the field caption (in red below) for the key. For example, if my form looked like the following image I can pass in the quantity by modifying the form URL and adding &Quantity=2 to the end of the URL (note it is case sensitive).

The full URL would look something like https://app.smartsheet.com/b/form?EQBCT=ded979748e9a4a200ff56a46a6e3afae&Quantity=2

set form value via url

Also, the field caption might have spaces or other special characters so it is important to URL encode these as well. For example, If I wanted to pass the "Product Name" in the URL I would add &Product%20Name=laptop to the URL.

Answering the Original Question

To answer the original question, you will want your URL to look like the following to send the Product Name.

 https://app.smartsheet.com/b/form?EQBCT=fbab5300a6d74cc58ae6326e267b3c4f&Product%20Name=driveway

This url can be dynamically generated by building the URL with javascript or passing the data via your own custom form. Since you are using a form in your example I will show that approach (which does not require javascript).

<form action="https://app.smartsheet.com/b/form" method="GET" >
    <input type="hidden" name="EQBCT" value="fbab5300a6d74cc58ae6326e267b3c4f" />
    <label for="productName">Product Name</label>: 
    <input type="text" name="Product Name" value="">
    <input type="submit" name="Send" />
</form>

Note that I added a hidden element containing the EQBCT key that was in the original URL.

Brett
  • 2,502
  • 19
  • 30
  • 1
    Please note that passing in field values via query string parameters is possible today but not officially supported. – avioing May 15 '14 at 23:55
  • how about passing multiple values like product name,product color and serial number via the url link? or it has to be done through custom form. – user3264403 May 16 '14 at 14:22
  • 1
    Yes, you can pass multiple values in the link. You just add &FieldCaption=Value to the end of the url for each item. For example, `https://app.smartsheet.com/b/form?EQBCT=fbab5300a6d74cc58ae6326e267b3c4f&Product%20Name=driveway&Product%20Color=grey&Serial%20Number=1234` – Brett May 16 '14 at 17:33
  • I'd like to create an sign up for newsletter form. I used this code
    :
    – user3264403 May 22 '14 at 02:14
  • but when I filled in the form with email addresses and after clicking submit button, it opens another Smartsheet form and empty. – user3264403 May 22 '14 at 02:28
  • 1
    @user3264403 the form in your comment has two issues. First, the action should be a full url starting with https://. Second, you used `name="Sign Up for Newsletter"` but that does not match the label in your form. Instead, you should use `name="Sign-up for newsletter"`. – Brett May 22 '14 at 17:49