Jump to content
  • 0

Update Form Set Field Blank


ChristianM

Question

I have an Update Form which has 2 fields:

Stock # (required)

Lot # (required)

After a user changes the Stock # for a record on the Update Page (but before submitting), I would like to set the Lot # field to blank. Then, because Lot # is required, a user would use a dropdown to select an updated Lot #. Currently, when a user changes the Stock #, the Lot # is already populated and users sometimes to forget to change that value as well (because it is already populated).

However, I am a bit stumped as to how I can set a field to blank in an Update Page. It doesn't look like I can set default values in an Update Page either. I cannot use Cascading Text Fields (table connecting Stock # to Lot #) either as this Lot # is routinely inaccurate and requires users to call specific facilities to verify the Lot #.

Has anyone ever run into this issue before?

Thank you in advance.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 1

Hi @ChristianM,

COuld you try this instead?

 

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
    document.querySelector("[id*='EditRecordField1']").addEventListener('keyup', function() {
        document.getElementById("EditRecordField3").value = "";
         });
});
</script>

 

Replace the Field1 and Field3 with your Stock and Lot field, respectively. You don't have to separate them with underscore just like how you did with your last response for "EditRecords_Stock" and "EditRecords_Lot_Location". If your fields are named Stock and Lot_Location, they should simply be just "EditRecordsStock" and "EditRecordsLot_Location"

 

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
    document.querySelector("[id*='EditRecordsStock']").addEventListener('keyup', function() {
        document.getElementById("EditRecordsLot_Location").value = "";
         });
});
</script>

 

This should work. If it doesnt, change the keyup to change

Link to comment
Share on other sites

  • 0

Hi @ChristianM,

So basically what you need is, whenever a new value is selected in the Stock field, the Lot field should then be empty and user would have to select option in there too.

 

You can use the following script on the Footer of the DataPage:

 

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
    document.getElementById('EditRecordField1').addEventListener('change', function() {
        document.getElementById("EditRecordField3").value = "";
         });
});
</script>

 

make sure to replace "Field1" in "EditRecordField1" with the name of your Stock field, and the "Field3" in the "EditRecordField3" with your Lot field.

 

On your Lot dropdown, you would also have to add another option there with a blank value

Link to comment
Share on other sites

  • 0

Hi @futurist

Thank you for your response!

I added the suggested code to my Footer and replaced the fields with my Stock and Lot Location fields.

image.png.c25a2c4710aed4e1dd3fbc8d4f96a158.png

 

 

I went to update a record to test. The original Stock and Lot location:

 

image.png.559701b54c65613757ecbab227c06da2.png

 

When I changed the Stock, however the Lot Location did not go blank as expected:

 

image.png.6df181b94b9b984cb1f5d6db9219656e.png

 

I did add a blank option to the table to select from

 

image.png.700fec1280ac31a26100d78e885bc23c.png

 

Any issues you can see?

 

Link to comment
Share on other sites

  • 0

Hi @ChristianM,

I thought your Stock field is a dropdown as well. It seems like it's a text field, so you can use the following:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
    document.getElementById('EditRecordField1').addEventListener('keyup', function() {
        document.getElementById("EditRecordField3").value = "";
         });
});
</script>

 

I used the keyup event instead of the change for the eventListener.

You would also wanna make sure that you have an option in the Lot Location dropdown whose VALUE is empty

Link to comment
Share on other sites

  • 0

@futurist thanks again for the code. Sorry that I didn't clarify that before.

The Stock field is an AutoComplete that pulls from a table.

The Lot Location field is a Dropdown that pulls from a table.

I realized that I had erased the "EditRecord" in my original code and have included it below in the Footer along with the two fields:

image.png.9e75904bb2b55447f2c28321eb520af8.png

 

I can confirm that a null VALUE exists in the Lot Location dropdown table:

image.png.07f0e8c42e36c6f1be57256d1f9665d2.png

Unfortunately, after changing the Stock, the Lot Location is still staying as the original value.

Any other ideas you might be able to think of? I greatly appreciate your assistance.

Link to comment
Share on other sites

  • 0

@futurist

My field names are [s_Stock] and [s_Lot_Location] which is why I included the underscores.

The following code worked perfectly. When the Stock field is altered, the Lot Location field now becomes blank.

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
    document.querySelector("[id*='EditRecords_Stock']").addEventListener('keyup', function() {
        document.getElementById("EditRecords_Lot_Location").value = "";
         });
});
</script>

Thank you so much!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...