Jump to content
  • 0

Prepopulate values-to-be-added so as to match search criteria


JohnM

Question

On a Tabular Report that includes a same-page Search Form, inline insertion of single records, and bulk editing, I want to preload fields so as to match the search criteria, before or after clicking ADD. 

For example, if I am looking at a results table filtered on State = Ohio, Make = Ford, Color= Blue, I do not want to enter those values again when I ADD a record. I want those values already in their fields (or added right after I hit ADD).

Even better, I would like the inserted record to have its left-side Edit selection checkbox already checked after the insertion. 

(I am comfortable with both JavaScript and SQL.)

Thanks for any suggestions!

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi JohnM,

If you want to autopopulate InlineInsert with values from your same-page Search Form, you can use the following code:

<script>
document.addEventListener('DataPageReady', function (event) {
       const search = document.querySelector('input[name="Mod0InlineAdd"]')
       search.addEventListener('mouseenter', getValues);
       search.removeEventListener('mouseleave', getValues);

       // Add how many elements you want populated, these are selectors for InlineInsert
       const inlineAddText = document.querySelector('input[name="InlineAddText255Field"]');
       const inlineAddNumber = document.querySelector('input[name="InlineAddNumberField"]');
       const inlineAddLocation = document.querySelector('input[name="InlineAddLocation"]');
  
       // These are fields from Search Form
       const searchText = document.querySelector('input[name="Value2_1"]');
       const searchNumber = document.querySelector('input[name="Value1_1"]');
       const searchLocation = document.querySelector('input[name="Value3_1"]');

       function getValues(){
            if(searchText.value.length > 0) inlineAddText.value = searchText.value;
            if(searchNumber.value.length > 0) inlineAddNumber.value = searchNumber.value;
            if(searchLocation.value.length > 0) inlineAddLocation.value = searchLocation.value;
       }
});

</script>

When you are about to click on the 'Add' button, fields in InlineAdd element should populate with values from corresponding search fields.

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...