Jump to content

Vitalikssssss

Caspio Evangelist
  • Content Count

    522
  • Joined

  • Last visited

  • Days Won

    52

Posts posted by Vitalikssssss

  1. Hi @Tyler,

    I can suggest using a different approach for this case that does not require JS snippet.

    You may create a lookup table that would be prefilled with date range Monday-Sunday (current week) with a help of Application Task.

    The Task might look like the following: 

    a6f7305064be.png

    You may use this lookup table as a source for a dropdown with predefined options.

    Hope this helps.

    Regards,

    Vitalikssssss

  2. Hi @JMR21,

    It is possible to add a JavaScript snippet on web-page. Basically you would need to place your datapages in some block elements and change the style property of the block from "display:block;" to "display:none;".  You may use "FormSubmitted" AJAX event of Caspio Datapage.

    Here is an example of web-page that has 3 DP deployed:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
    
    <div id="page_1">
        <script type="text/javascript" src="https://xxxxxxx.caspio.com/dp/498c4000904cc6b6744049ea8b30/emb"></script>
    
    </div>
    
    <div id="page_2" style="display: none;">
    
        <script type="text/javascript" src="https://xxxxxxxx.caspio.com/dp/498c4000802149cd8ef64f44a37b/emb"></script>
    
    </div>
    
    <div id="page_3" style="display: none;">
        <script type="text/javascript" src="https://xxxxxxxxx.caspio.com/dp/498c4000e67cc919259840428b77/emb"></script>
    </div>
    
    
    
    <script type="text/javascript">
    document.addEventListener('FormSubmitted', function(event) {
    //checks if user forgot to input all required fields    
    let err = document.querySelector(".cbFormCommonError");
    	if (event.detail.appKey == '498c4000904cc6b6744049ea8b30' && !err ) {
                  document.getElementById("page_1").style.display = "none";
                  document.getElementById("page_2").style.display = "block";
           	} else if (event.detail.appKey == '498c4000802149cd8ef64f44a37b' && !err)    {
                  document.getElementById("page_2").style.display = "none";
                  document.getElementById("page_3").style.display = "block";
    	}
    });
    </script>
    
        
    </body>
    </html>

    Also, you may consider using an approach of rendering datapage "on fly" explained in this post. 

    Hope this helps.

    Regards,

    vitalikssssss

  3. Hi @Mitch,

    Perhaps you will find below tutorial useful.

    Also, in order to start using REST API you need to have a solid knowledge of any back-end language. I would recommend learning the PHP since in my opinion it is the easiest to learn. 

    There a lot of training materials on PHP available in the web. 

    There is a post with PHP code samples that you may find useful too: 

     

    Hope this helps.

    Regards,

    vitalikssssss

     

  4. Hi @achatwani,

    Please try the following JavaScript:

    <script type="text/javascript">
    
    
    document.addEventListener('DataPageReady', function (event) {
      
      var suffix = event.detail.uniqueSuffix;
      
      document.querySelector(".cbFormSelect").addEventListener("change", myFunction);
    
      function myFunction(){
         
        var button = document.querySelector(`#searchID${suffix}`);
         if(button) {
    
          button.click();
          
        }
    
      }
      
      });
    
    </script>

    Place it in the Footer of Search Form and make sure that you have disabled HTML editor prior to inserting the code.

    Hope this helps.

    Regards,

    vitalikssssss

     

  5. Hi @Paolo,

    You may use timeout setting of authentication in order to log-out the user.

    • Time out and redirection – Configure session expiration after user inactivity and provide a page or URL to redirect timed out users.

    You can set the interval when authentication session will expire, however the log-out will happen only after session expires and user tries to do some action on a form.

    It will not be possible to terminate the session of the user simply closes a browser tab or browser.

    If you are looking for automatic log out even if user left the page open, then you can use the following JavaScript:

    <script type="text/javascript">
    document.addEventListener('DataPageReady', ()=>{
    
        setTimeout(()=>{
    
            window.location = "https://xxxxxxxx.caspio.com/folderlogout"; //your logout URL from caspio authentication
    
        }, 5000); // duration of session in milliseconds 
    });
    
    </script>

    Hope this helps.

    Regards,

    vitalikssssss

  6. Hi @Paolo,

    Caspio offers custom events if you have AJAX enabled.

    The one that you need to use called "BeforeFormSubmit" it occurs after user clicks on "Submit" button, but unfortunately before the default form validation checks(*required) happens.

    I can suggest to write all validation needed in JavaScript and use "BeforeFormSubmit" event.

    Here is documentation: https://howto.caspio.com/datapages/ajax-loading/

    Hope this helps.

    Regards,

    vitalikssssss

  7. Hi @DesiLogi,

    It is possible with JavaScript to disable Cascading dropdown, however I would recommend using a Cascading TextField that has an option to disable the input field if only one option returned.

    If my suggestion does not fit your workflow than you can use the following JavaScript:

    <script>
    document.addEventListener('DataPageReady', function (event) {
        const el = document.querySelector('select[id^="InsertRecordYOUR_FIELD"]');
        el.addEventListener('change', ()=>el.disabled="true");   
    });
    </script>

    Regards,

    vitalikssssss

  8. Hi @maramedinan,

    Solution provided above will not work unless the code placed in HTML block (row element).

    I have created a different snippet for highlighting some particular cell that you can try. 

    Please make sure that you replace number that refer to the column number in below code. Column count starts with "1".

    The following code should go into DataPage Footer.

    <script>
    
    document.addEventListener('DataPageReady', function(event){
    
      let arr = document.querySelectorAll('td:nth-child(4).cbResultSetCalculatedField'); //change number of the column in "nth-child(4)"  
    
      arr.forEach(element => {
    
    
        if (element.innerHTML > 7) { // your target value
            
            element.style.background = 'red'; // color that would be applied on cell that meets the criteria
        }
    
      });
    
    });
    
    </script>

    Hope this helps.

    Regards,

    Vitalikssssss

  9. Hi @JanineB,

    It looks like the "$" currency sign added by formatting is the reason for element value not been recognized as a number.

    You may add a replace function with regex to remove unwanted characters from value formatted as currency.

    So, your JavaScript would look like this:

    <script>
      
    var elems = document.getElementsByTagName("td");
      
    for (var i=0, m=elems.length; i<m; i++) {
      
    if (elems[i].innerHTML.replace(/[^0-9\.-]+/g,"") > 0) { 
      
        elems[i].style.textDecoration = "line-through";
    
        }
      
    }
    </script>

    Regards,

    vitalikssssss

  10. Hi @jazmichaelking,

    It looks like G Suite supports SAML 2.0 (Security Assertion Markup Language) that also used by Caspio SAML, however G Suite is not listed as one of the Idp provider that has been verified by Caspio. I haven`t done this type of integration yet  but overall it should be possible. The only challenge I see is to understand how to store usernames in Caspio table. I guess it is possible to find out the format of user_name returned by Idp from G Suite support.

    Here are some links that should help:

    https://howto.caspio.com/authentications-and-connections/single-sign-on/

    https://support.google.com/a/answer/6087519

    Hope this helps.

    I would appreciate if you share with a community if you succeed or not.

    Regards,

    vitalikssssss   

     

     

×
×
  • Create New...