Jump to content

KlisaN137

Caspio Ninja
  • Posts

    35
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by KlisaN137

  1. Hi @Fleshzombie,

    I have managed to replicate the exact behavior, it looks that when using 'window.location.href', other than our parameter, appSession get passed as well:

    image.thumb.png.3bb0526a45012f4279daebeb8e92c80d.png

    I however don't know if that is causing the described error.

    About the difference between these two ways of using the feature, I found that 'window.location.href' is triggerable in JavaScript, and <a href=''> is just hyperlink in HTML.

    More on the page:

    https://stackoverflow.com/questions/61553496/whats-the-differences-between-window-location-href-and-a-href-a

  2. Hi @deemuss

    You can use one of the following codes in the Footer of the DataPage:

    1. With this one, link will still be on the screen, but it would not redirect anywhere:

    <a  id='aLink' href="[@app:URL_1]">Caspio</a>
    
    <script>
    document.addEventListener('DataPageReady', function (event) {
          const link = document.querySelector('#aLink');
          const message = document.querySelectorAll('.cbResultSetRecordMessage')[0];
          if(message.textContent === 'No records found.') link.href = 'javascript:void(0)';
    });
    </script>

     

    2. This one will remove link from the page:

    <a  id='aLink' href="[@app:URL_1]">Caspio</a>
    
    <script>
    document.addEventListener('DataPageReady', function (event) {
          const link = document.querySelector('#aLink');
          const message = document.querySelectorAll('.cbResultSetRecordMessage')[0];
          if(link){
               if(message.textContent === 'No records found.') link.remove();
          }
    });
    </script>

     

  3. Hi @BobHike

    If passing parameters through Caspio, it makes no difference are you passing one or multiple parameters, you just need to use proper names.

    If passing parameters through query string, there is an example of using multiple parameters:
    https://howto.caspio.com/parameters/parameters-as-query-string-values/

    Basically, parameters here are separated with '&' sign.

    About configure screens, Search and Report DataPages has three - one for configuring the search fields, one for configuring report fields, and one more if you are using Details page.

    I hope this clears things a bit.

  4. Hi @biota,

    #Inserted is the data that is being inserted to the table. Please see the following:

    https://howto.caspio.com/tables-and-views/triggered-actions/

    In your case, when you insert new record to the table, it will look it the 'Sources_lkp' table, and find if there are record that has the same 'source_name' as 'historical_feature_name' from your inserted record. It will than populate fields 'Source_ID', 'significance_site' and 'contaminants_site' with values from the selected fields from 'Sources_lkp' table with that same 'source_name' as 'historical_feature_name'.

  5. Hi @MarkMayhrai,

     

    In order to prevent users from submitting by pressing Enter, you may want to add another EventListener on 'BeforeFormSubmit':

    document.addEventListener('BeforeFormSubmit', function(event) {
          event.preventDefault();
    });

    Actually, by using event.preventDefault() in the fist event listener nothing is achieved, because the 'event' here is not submission, but changing of value in 'WayBillID' field.

    The whole code should be then something like this:

    <script>
    
    document.querySelector('input[name="InsertRecordWayBillID"]').addEventListener('change', function (event) {
     
       var check = document.querySelector('input[name="InsertRecordWayBillID"]').value;
       if (check.length>0){
       var MarkUp = document.getElementsByName('cbParamVirtual7')[0].value;
       var Msgtocheck = "WayBill already scanned, duplicates not allowed";
           if (MarkUp != Msgtocheck) {
               event.preventDefault();
           } 
       }
    
    });
    
    document.addEventListener('BeforeFormSubmit', function(event) {
       event.preventDefault();
    });
    </script>

     

  6. Hi@kpcollier

     I'm not sure we can easily change the text in 'Choose File' button. I've looked at the following places:

    https://docs.microsoft.com/en-us/answers/questions/567773/change-34choose-file34-and-34no-file-chosen34-text.html
    https://stackoverflow.com/questions/1944267/how-to-change-the-button-text-of-input-type-file

    But, it seems that Caspio use slightly different code for a input file element, you can maybe try temper with it yourself...

  7. Hi @MarkMayhrai,

    In order to prevent submission you may check the following Forum Post:

     

    As the autosubmit part, I'm guessing you are using JS from the page:

    To prevent submission if there is an error in Form, you may use this code instead:

    <script type="text/javascript"> 
    
    document.addEventListener('DataPageReady', function (event) {
               const error = document.querySelector('div[data-cb-name="HeaderErrorMsg"]');
               if(!error){
                    if(document.getElementById("caspioform")) {
                    document.getElementById("caspioform").style.display = 'none';
                    setTimeout('document.forms["caspioform"].submit()',1000); } 
               }    
    });
    
    </script>

    I'm not sure how are you checking if the entry is a duplicate? What is the indication that some record is duplicate?

  8. @jbloome for implementing it on Details, instead of 'InsertRecordFIELDNAME', you must use 'EditRecordFIELDNAME', and place the code not in the Footer of the page, but add a new HTML block element just after all other elements, and put the code there.

    Also, additional event listener is needed, here is the entire code:

    <script>
    document.addEventListener('DataPageReady', function (event) {
    
        const fields = ['EditRecordPhone1','EditRecordPhone2', 'EditRecordPhone3'];
        const inputs = [];
    
        for (let f of fields){
               inputs.push(document.querySelector('#' + f));
        }
    
        for(let i of inputs){
           i.maxLength = 14;
           i.onkeyup = telephize;
           i.onkeydown = telephize;
        }
    
      function telephize(v_e) {
        // this.value = this.value.replace( /\D+/g, "" ).replace( /([0-9]{1,3})([0-9]{3})([0-9]{4}$)/gi, "($1) $2-$3" ); //mask numbers (xxx) xxx-xxxx
    
        v_e = v_e || window.event;
        if (v_e.keyCode >= 65 && v_e.keyCode <= 90) {
         this.value = this.value.substr(0, this.value.length - 1);
         return false;
        } else if (v_e.keyCode >= 37 && v_e.keyCode <= 40) {
         return true;
        }
        var v_value = (this.value.replace(/[^\d]/g, ''));
        if (v_value.length == 7) {
         this.value = (v_value.substring(0, 3) + "-" + v_value.substring(3, 7));
        } else if (v_value.length == 10) {
         this.value = ("(" + v_value.substring(0, 3) + ") " + v_value.substring(3, 6) + "-" + v_value.substring(6, 10));
        };
       }
    
        document.querySelector('#caspioform').onsubmit = function(e) {
            e.preventDefault();
    
    
        if (input.value.length >= 14){
        this.submit();
        } else {
        alert('Please input a valid phone number');
        input.focus();
        }
        }
    });
    </script>

     

  9. Hi  @telepet

    If it is a Tabular Report, I'm guessing you want this on Details Page?

    Yes, you need to adjust Element ID, in this case, where you see 'EditRecord' and 'Remove', just follow the same logic. Also, add another part to get rid of the label 'remove':

    <script>
    var UploadA='[@field:FIELDNAME]';
    
    if (UploadA.length>0)
        {
    document.getElementById("EditRecordFIELDNAME").style.visibility = 'hidden';
    document.getElementById("EditRecordFIELDNAMERemove").style.visibility = 'hidden';
    document.querySelector('label[for="EditRecordFIELDNAMERemove"]').style.visibility = 'hidden';
        }
    
    </script>

    Please instead of using the code in the Footer of the page, add another HTML block element just after the last element, and put the code in it, this will execute code again when the file is uploaded after using Update button.

  10. 1) You can store picture files, and just reference it on a DataPage, it will be shown as picture: https://howto.caspio.com/files-and-images/uploading-files-and-images/

     

    2) If you are storing quotes in table with fields quote and date, so every quote is having the corresponding date, you could use Calculated Value to find the right quote based on the date:

    SELECT Quote FROM Quotes WHERE Date = CONVERT(DATE, SysUTCDateTime())

     

    3) For setting a background, please check the following articles:

    https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/how-to-dynamically-change-the-background-of-a-results-page

    https://howto.caspio.com/faq/styles-and-localization/how-to-use-an-image-as-form-background/

    https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/customize-background-and-font-colors-in-report-datapage/

  11. Hi @jbloome and @Meekeee

    We can also use arrays and loops to further reduce the code:

    <script>
    
    const fields = ['InsertRecordPhone1','InsertRecordPhone2', 'InsertRecordPhone3'];
    const inputs = [];
    
    for (let f of fields){
           inputs.push(document.querySelector('#' + f));
    }
    
    for(let i of inputs){
        i.maxLength = 14;
        i.onkeyup = telephize;
        i.onkeydown = telephize;
    }
    
    function telephize(v_e) {
        // this.value = this.value.replace( /\D+/g, "" ).replace( /([0-9]{1,3})([0-9]{3})([0-9]{4}$)/gi, "($1) $2-$3" ); //mask numbers (xxx) xxx-xxxx
    
        v_e = v_e || window.event;
        if (v_e.keyCode >= 65 && v_e.keyCode <= 90) {
         this.value = this.value.substr(0, this.value.length - 1);
         return false;
        } else if (v_e.keyCode >= 37 && v_e.keyCode <= 40) {
         return true;
        }
        var v_value = (this.value.replace(/[^\d]/g, ''));
        if (v_value.length == 7) {
         this.value = (v_value.substring(0, 3) + "-" + v_value.substring(3, 7));
        } else if (v_value.length == 10) {
         this.value = ("(" + v_value.substring(0, 3) + ") " + v_value.substring(3, 6) + "-" + v_value.substring(6, 10));
        };
       }
    
    document.querySelector('#caspioform').onsubmit = function(e) {
        e.preventDefault();
    
    
    if (input.value.length >= 14){
    this.submit();
    } else {
    alert('Please input a valid phone number');
    input.focus();
    }
    }
    
    </script>

     

  12. Hi, @drckarcher,

    In order to show some field on the Form DataPage from the entry that has most recent timestamp, we can use the Virtual Field with Calculated Value with the following SQL statement:

    SELECT TOP(1) field_we_want_to_show FROM tbl_test ORDER BY Time_Stamp_Field DESC

    I'm not sure if I understand would you like to show last allocation based on some value from other field, so could you please elaborate a little bit more about the issue?

  13. Hi @CoffeeLover,

     

    Thank you for explanation. As far as I can see, because the values of authentication fields are taken at the moment of login, they remain unchanged during the entire session. Only way to refresh data is starting a new session - log out and then again log in.

    I found this Forum thread about that also:

    I'm guessing that for required workflow, you might need to use additional table.

  14. Hi @CoffeeLover,

    To update user authentication fields, you can use Single Record Update DataPage, with the Users table as the Data Source. Then you can restrict access to the page based on Authentication:

    https://howto.caspio.com/datapages/forms/update-forms/

    I'm not sure what do you mean by "How can I have the users authfields updated if changed? (without them logging off and loggging back in)", could you specify a little bit more?

  15. @skwaler As I checked, it may not be possible to update the parent DataPage when data from it are updated on the separate pop up page. Refer to the below Posts:

     

    It is possible to refresh the page at some time interval, but I suspect that is not the intended workflow here...

    Have you considered using Inline Edit or Grid Edit on your Report DataPage instead of pop up? That way, if records are edited, the DataPage is updated. Please refer to the:
    https://howto.caspio.com/datapages/reports/data-editing-options-in-reports/

    Anyway, I will continue to look onto this issue, and will update here if I find something.

×
×
  • Create New...