Jump to content
  • 0

Place draft text from other field in data source in T64000 field for user to modify 


KG360

Question

I'd like to pre-populate T64000 fields with suggested text from the data source (in a submission form) that the user can modify to their liking. 

Any hint on how to accomplish this is appreciated!

/KG

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hello @KG360,

As far as I understood, you want to retrieve the text stored in the table and it depends on the value(s) populated by the user.

If this is correct, I can suggest the following:

1) Add a Virtual field that is set as a Calculated value to get the text from the table. This Virtual field can be hidden by checking the 'Hide field' checkbox on the Advanced tab.

For example:

SELECT Comment FROM table_222 WHERE ID = target.[@field:User_ID]

2) Add the code in the Footer (disable the HTML editor before pasting the code).

In this example, I use the Virtual 1 field and the 'Comment' field. Please use corresponding names.

<script>
document.addEventListener('DataPageReady', copyTextHandler)
  
function copyTextHandler(){

    const virtualField = document.querySelector('input[id*="cbParamVirtual1"]'); //replace the Virtual field number if needed
    const textField = document.querySelector('[id*="InsertRecordComment"]'); //use your field name
    
    virtualField.addEventListener("change", (event) => {
         let calcValue = event.target.value;
         if(calcValue !=="") {
            textField.value = calcValue;
        }
    })  
     document.removeEventListener('DataPageReady', copyTextHandler);
}

</script>

This is the DataPage example. The text retrieved by the Calculated value is copied to the 'Comment' field by JavaScript. The 'Comment' field is set as a Text Area.

EbdbFDX.png

Link to comment
Share on other sites

  • 0
4 hours ago, CoopperBackpack said:

Hello @KG360,

As far as I understood, you want to retrieve the text stored in the table and it depends on the value(s) populated by the user.

If this is correct, I can suggest the following:

1) Add a Virtual field that is set as a Calculated value to get the text from the table. This Virtual field can be hidden by checking the 'Hide field' checkbox on the Advanced tab.

For example:

SELECT Comment FROM table_222 WHERE ID = target.[@field:User_ID]

2) Add the code in the Footer (disable the HTML editor before pasting the code).

In this example, I use the Virtual 1 field and the 'Comment' field. Please use corresponding names.

<script>
document.addEventListener('DataPageReady', copyTextHandler)
  
function copyTextHandler(){

    const virtualField = document.querySelector('input[id*="cbParamVirtual1"]'); //replace the Virtual field number if needed
    const textField = document.querySelector('[id*="InsertRecordComment"]'); //use your field name
    
    virtualField.addEventListener("change", (event) => {
         let calcValue = event.target.value;
         if(calcValue !=="") {
            textField.value = calcValue;
        }
    })  
     document.removeEventListener('DataPageReady', copyTextHandler);
}

</script>

This is the DataPage example. The text retrieved by the Calculated value is copied to the 'Comment' field by JavaScript. The 'Comment' field is set as a Text Area.

EbdbFDX.png

Magnificent, thank you @CoopperBackpack !! This works beautifully. I wish I had asked this sooner. With my previously limited knowledge, I presented the proposed template text and ask the user to copy and paste it and then change it to their liking. This solution is far more elegant! Thanks! 

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