Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 05/11/2024 in Posts

  1. You can achieve this by doing the following: Remove your STOCK field and add an HTML block that will act as the Stock column. Label the HTML Block as "STOCK". Disable HTML editor in the HTML block advanced options tab. Copy and paste the code below into the HTML block: Replace the 7 instances of FIELDNAME below with the name of your STOCK Field. You can adjust the color, background color, and padding in each statement below as needed. <div id="mydiv[@field:ID]"> </div> <SCRIPT LANGUAGE="JavaScript"> if ("[@field:FIELDNAME]" == "A") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:white;background-color:red;padding:6px;'> [@field:FIELDNAME]</span>"; else if ("[@field:FIELDNAME]" == "B") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:black;background-color:yellow;padding:6px;'> [@field:FIELDNAME]</span>"; else if ("[@field:FIELDNAME]" == "C") { document.getElementById("mydiv[@field:ID]").innerHTML ="<span style='color:white;background-color:green;padding:6px;'> [@field:FIELDNAME]</span>"; } else{ document.getElementById("mydiv[@field:ID]").innerHTML ="[@field:FIELDNAME]"; } </SCRIPT> See this article for more info:
    1 point
  2. Hello @CoopperBackpack I want to express my deepest gratitude for this solution; flawless, it worked perfectly. Also, thank you for pointing out this article. Although I've seen it a few times before, it didn't really make much sense until now. I'll assimilate this knowledge for future endeavors. Many thanks, @CoopperBackpack
    1 point
  3. Hello @Buggy, If the Trigger is not an option for you, of course you can use JS. I tested the code I provided and it works on my side for the same scenario. Do you see any errors in the browser console after the code is added? (to check the console you need to click F12)
    1 point
  4. Hi Caspians I had a use case where we needed to enforce users entering only text in text input fields (no numbers/special characters allowed) Below is a solution that can be used for submission form/details DataPages. The code can be added to the header or footer: <script> if (document.addInputListener == undefined) { const txtInputNames = ['Txt1', 'Txt2'] const errorMessage = 'Please enter text only' const addInputListener = () => { txtInputNames.forEach(inputName => { document.querySelectorAll(`form[action*="[@cbAppKey]"] input#InsertRecord${inputName}, form[action*="[@cbAppKey]"] textarea#InsertRecord${inputName}, form[action*="[@cbAppKey]"] input#EditRecord${inputName}, form[action*="[@cbAppKey]"] textarea#EditRecord${inputName}`).forEach(HTMLInput=>{ HTMLInput.addEventListener('input', e=>{ e.target.value = e.target.value.replace(/\s{2,}/g, ' ') if (/^[A-Za-z\s]+$/.test(e.target.value)) { e.target.setCustomValidity('') return} e.target.setCustomValidity(errorMessage) e.target.value = e.target.value.replace(/[^A-Za-z\s]/g, '') e.target.reportValidity() }) }) }) } const DataPageReadyHandler = (e) => { if (e.detail.appKey != '[@cbAppKey]') { return } addInputListener() } document.addEventListener('DataPageReady', DataPageReadyHandler) document.addInputListener = 'Enabled' } </script> You would need to customize this array so it holds comma-separated names of your text fields where you need to enforce this solution: const txtInputNames = ['Txt1', 'Txt2'] Here you can customize the message that users will see when entering something other than text: const errorMessage = 'Please enter text only'
    1 point
  5. Hi, you may also want to check out some of the datediff function that you can refer here as well: https://howto.caspio.com/faq/reports-datapages/calculated-fields-and-datediff-function/
    1 point
  6. Hello, @Sam23! If you wish to change the date format, you may use the formula below. CONVERT(DATETIME,[@field:K2_Contact_Birthday],110) For list of different format, you may check this link: https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/ -Potato
    1 point
  7. Hi @Sam23 - you can convert your whole formula to text and then add the 'y/o'. You can do this as reference: CONVERT(varchar(10),Datediff(year, [@field:DOB], SysUTCDateTime())) + ' years old' Result: Hope this helps!
    1 point
×
×
  • Create New...