KG360 Posted March 2 Report Share Posted March 2 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 Quote Link to comment Share on other sites More sharing options...
0 CoopperBackpack Posted March 4 Report Share Posted March 4 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. KG360 1 Quote Link to comment Share on other sites More sharing options...
0 KG360 Posted March 4 Author Report Share Posted March 4 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. 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! CoopperBackpack 1 Quote Link to comment Share on other sites More sharing options...
Question
KG360
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
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.