Elderberg 2 Posted April 30, 2020 Report Share Posted April 30, 2020 Inspecting the webpage I see that caspio in some cases appends an alphanumeric code to a virtual field ex: cbParamVirtual23_5cc2f7c259e4b5 I've read and used fairly successfully the following to reference the value: document.querySelector('[id*=cbParamVirtual23]'); My question: is there a more explicit way to reference this virtual field? Reason being the asterisk is a wildcard and it gets messy when referencing cbParamVirtual2 if there is a cbParamVirtual23 present prior. Quote Link to post Share on other sites
Vitalikssssss 67 Posted April 30, 2020 Report Share Posted April 30, 2020 Hi @Elderberg, You may add underscore after the field name if you would like to reference Virtual field #2^ document.querySelector('[id*=cbParamVirtual2_]'); Regards, vitalikssssss Quote Link to post Share on other sites
Elderberg 2 Posted April 30, 2020 Author Report Share Posted April 30, 2020 Thanks Vitaliksssss. however, is there a way to capture and reference the alphanumeric key that's appended? I have a use case where i'm using the following fields in my table: - fno1_paytype - fno1_Start_Time - fno1_End_Time - fno1 I'm having trouble accessing fno1 because document.querySelector("[id*=InsertRecordfno1_]"); isn't catching the correct field Ultimately I may have to rename fields, but since I have a lot of javascript, as well as multiple datapages already built and working which references the above table fields, renaming would be a worst case scenario. Quote Link to post Share on other sites
Vitalikssssss 67 Posted May 26, 2020 Report Share Posted May 26, 2020 Hi @Elderberg, I have recently found that you can get suffix from DataPage event. <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { let suffix = event.detail.uniqueSuffix; console.log(suffix); }); </script> Regards, vitalikssssss Elderberg 1 Quote Link to post Share on other sites
Elderberg 2 Posted May 31, 2020 Author Report Share Posted May 31, 2020 Excellent. thank you. I will give this a try next time. I ended up renaming my fields, it wasn't as time consuming as I thought, but will look into what you've shared in future scenarios. Quote Link to post Share on other sites
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.