Jump to content

Vitalikssssss

Caspio Rockstar
  • Content Count

    409
  • Joined

  • Last visited

  • Days Won

    41

Posts posted by Vitalikssssss


  1. Hi @kpcollier,

    Try the following JavaScript:

    <script type="text/javascript">
    
    function formatAsDollars(el) {
    el.value = el.value.replace(/[^\d]/g,'').replace(/(\d\d?)$/,'$1').replace(/^0+/,'').replace( /\d{1,3}(?=(\d{3})+(?!\d))/g , "$&,");
    el.value = el.value ? '$' + el.value : '';
    }
    
    var fields = ["Subtotal", "MarkUp", "County_Tax", "Misc_Percent", "Freight_Total"]; //specify your fields here
    
    fields.forEach(element => {
        element = "InsertRecord" + element; // replace "InsertRecord" with "EditRecord" for Details/Single Record Update DP 
        document.getElementById(element).onkeyup = function() {
            formatAsDollars(this);
        }
        document.getElementById(element).onchange= function() {
            formatAsDollars(this);
        }
    });
    
    function calculate() {
    
        var subTotal = document.getElementById("InsertRecordSubtotal").value.length == 0 ? 0 : (parseFloat(document.getElementById("InsertRecordSubtotal").value.replace(/[$,]+/g,"")));
        var markUp = document.getElementById("InsertRecordMarkUp").value.length == 0 ? 0 : (parseFloat(document.getElementById("InsertRecordMarkUp").value.replace(/[$,]+/g,"")));
        var countyTax = document.getElementById("InsertRecordCounty_Tax").value.length == 0 ? 0 : (parseFloat(document.getElementById("InsertRecordCounty_Tax").value.replace(/[$,]+/g,"")));
        var miscPerc = document.getElementById("InsertRecordMisc_Percent").value.length == 0 ? 0 : (parseFloat(document.getElementById("InsertRecordMisc_Percent").value.replace(/[$,]+/g,"")));
        var freight = document.getElementById("InsertRecordFreight_Total").value.length == 0 ? 0 : (parseFloat(document.getElementById("InsertRecordFreight_Total").value.replace(/[$,]+/g,"")));
    
    
        var markUpTotal = document.getElementById("InsertRecordMarkUp_Total").value = (subTotal) * (markUp);
        
        var countyTaxTotal = document.getElementById("InsertRecordCountyTax_Total").value = (subTotal) * (countyTax);
        
        var miscPercTotal = document.getElementById("InsertRecordMisc_Percent_Total").value = (subTotal) * (miscPerc);
        
        var total = document.getElementById("cbParamVirtual1").value = (subTotal) + (markUpTotal) + (countyTaxTotal) + (miscPercTotal) + (freight);
      
        var dp_el = [
            document.getElementById("InsertRecordMarkUp_Total"),
            document.getElementById("InsertRecordCountyTax_Total"),
            document.getElementById("InsertRecordMisc_Percent_Total"),
            document.getElementById("cbParamVirtual1")
        ];
    
        dp_el.forEach(element => formatAsDollars(element));
    
     }
     
    setInterval(calculate, 1500);
    
    
    </script>

    Regards,

    vitalikssssss


  2. Hi @walkerc,

    You will not be able to build a View with desired output because Joins cannot be configured with OR logic.  

    I can suggested using a filtering criteria on Datapage in order to show the records from Main_Data table to the Contractor.

    You should use a Main_Data as a data source for your Datapage. Also you should enable authentication which based on "Contractor_Data" table for this Datapage.

    Finally you can use the following filtering logic:

    P.S. use TradingName i.o. Record_ID from my sample.

    tZBYRRd.png

     Hope this helps.

    Let me know if you have any questions.

    Regards,

    vitalikssssss

     

     

     


  3. Hi @SonniT,

    I am pretty much sure that you receive an error because you have used PK_ID field as body parameter.

    PK_ID is a system field which acts as a record index for Caspio Table. I am afraid that you cannot use this field in body parameters.

    Try removing this parameter from body to resolve the issue.

    Please provide us with fields Data type used in the table if you still encounter an issue after removing PK_ID.


    Regards,

    vitalikssssss 

     

     


  4. Hi @EmmePGN,

    The following script fires the selection check after user clicks on Update button in his form:

    <script type="text/javascript">
     var v_state = "[@field:TypesWrittenComm]" ;
     var o_state = document.getElementById("EditRecordTypesWrittenComm") ;
     o_state.multiple = true ;
    
     function f_listbox() {
      if ( v_state.indexOf(",") > 0 ) {
       for (var i=0 ; i < o_state.options.length; i++ ) {
        if(o_state[i].value == v_state) {
         o_state.remove(i);
         break ;
        }
       }
       var o_st = v_state.split(", ") ;
       for (var j=0 ; j < o_st.length; j++) {
        for (var i=0 ; i < o_state.options.length; i++ ) {
         if(o_st[j]== o_state.options[i].value){
          o_state.options[i].selected = true ;
          break ;
         } 
        }
       }
      }
     }
     
    function check_listbox()
    {
       var maximum_selections = 3;
       var MyListbox = document.getElementsByName("EditRecordTypesWrittenComm")[0];
       var number_selections = 0;
       for (var i=0; i<MyListbox.length; i++)
       {
          if (MyListbox.options[i].selected) number_selections++;
        }
       if (number_selections>maximum_selections)
       {
         alert("You can select only " + maximum_selections + " items");
         event.preventDefault();
        }
    }
    
    
    document.addEventListener('BeforeFormSubmit', function(event) {
    	check_listbox();
    
    });
    
    </script>

    Hope this helps.

    Regards,

    vitalikssssss


  5. Hi @Chrille,

    You should use "EditRecord" prefix on Details page in order to reference a field.

    So, you code should look like this:

    <script type="text/javascript">
    
    document.addEventListener('BeforeFormSubmit', function (event) {
    
    
    var v3 = '<img src="http://image_url" alt="YES"';
       var v2 = document.getElementById("EditRecordKontaktad").value;
       if (v2 !="")
    {
    document.getElementById("EditRecordRingt").value = v3;
    
    }});
    </script>

    Hope this helps.

    Regards,

    vitalikssssss


  6. Hi @EmmePGN,

    There are different ways how you can tackle this challenge.

    You may use a JavaScript or you create an expression which results in SQL error.

    Here is a JavaScript which will hide the "Submit" button if user selection exceed "100":

    <script>
    
    function checkLimit(){
      
        let value = document.querySelector('input[id*="InsertRecordYOUR_FIELD"]').value; //enter your actual field name
        let button = document.querySelector('input[id^="Submit"]');
    
        if (value > 100) {
    
            button.style.visibility = "hidden";
        }
    
        else { 
    
            button.style.visibility = "visible";
        }
    
    }
    
    setInterval(checkLimit, 500)
    
    </script>

    This code should go into Footer of the Datapage and also make sure you disabled an HTML editor.

    Second option is to have the expression in Calculated value field which results in SQL error, e.g.

    CASE WHEN
    
    (Isnull([@field:PointFactor_Duties_PercentDuty1],0)+Isnull([@field:PointFactor_Duties_PercentDuty2],0)+Isnull([@field:PointFactor_Duties_PercentDuty3],0)+Isnull([@field:PointFactor_Duties_PercentDuty4],0)+Isnull([@field:PointFactor_Duties_PercentDuty5],0)+Isnull([@field:PointFactor_Duties_PercentDuty6],0)) > 100
    
    THEN CAST( 'a' + 1 as INT)
    
    ELSE (Isnull([@field:Number_1],0) + Isnull([@field:Number_2],0) + Isnull([@field:Number_3],0))
    
    END

    User will see an error if he enters amount which exceeds "100".

    EHC5oo6.png

    Message can be customized in Localization.

    Hope this helps.

     

    Regards,

    vitalikssssss

     


  7. Hi @bbewley, @kpcollier,

    You may try using this JS which should go to the Footer:

    <script type="text/javascript">
    
    function formatAsDollars(el) {
    el.value = el.value.replace(/[^\d]/g,'').replace(/(\d\d?)$/,'$1').replace(/^0+/,'').replace( /\d{1,3}(?=(\d{3})+(?!\d))/g , "$&,");
    el.value = el.value ? '$' + el.value : '';
    }
    
    let fields = ["FIELD_1", "FIELD_2"]; //specify your fields here
    
    fields.forEach(element => {
        element = "InsertRecord" + element; // replace "InsertRecord" with "EditRecord" for Details/Single Record Update DP 
        document.getElementById(element).onkeyup = function() {
            formatAsDollars(this);
        }
        document.getElementById(element).onchange= function() {
            formatAsDollars(this);
        }
    });
    </script>

    Pay attention to comments.

    Hope this helps.

    Vitalikssssss


  8. Hi @JSLane,

    It is doable in Caspio.

    You should use separate form (Submission Form Datapage) which passes a parameter to the Report Datapage.

    The trick here is that you will have multiple fields in report datapage which receive a single parameter.

    This concept described in the following article:

    https://howto.caspio.com/faq/reports-datapages/how-to-do-keyword-search-across-multiple-fields/

    I would also suggest watching the following tutorial video which explains how to pass parameters between separate form embedded on single web-page.

    https://www.youtube.com/watch?v=K3CKFjuSIt4

    Hope this helps.

    Regards,

    vitalikssssss

     


  9. Hi @DTINVN,

    I am afraid that you cannot use SQL in HTML blocks.

    SQL code can be only used in Calculated values\fields.

    I would recommend using a JS code in order to achieve described behavior.

    1. Add the following code into HTML block:

    <p id="[@cbRecordIndex#]"></p>

    2. Add the following JS into Datapage Footer:

    <script type="text/javascript">
    document.addEventListener('DataPageReady', function (event) {
    
    let el = document.querySelectorAll('td>p');
    let par = '[@BU]';
    
    el.forEach(element => {
        if(par=='8') element.innerHTML = '<span month_year="[@field:Month_Year*]" sub_type="[@field:Function_Subtype#]">[@field:MPBU_HC]</span>';
        else if (par=='6') element.innerHTML = '<span month_year="[@field:Month_Year*]" sub_type="[@field:Function_Subtype#]">[@field:MicBU_HC]</span>';
        else element.innerHTML = '0';
    });
           
    });
    </script>

    Please make sure that you disable HTML editor before inserting the code.

    Regards,

    vitalikssssss


  10. Hi @guardmetrics,

    Formula field performs calculation within a record and it cannot be used for cross table calculation.

    You should consider using Calculated fields on Report/Details datapages with SQL in order to perform cross-table calculation.

    Here is an article which explains how to use SQL in Calculated fields:

    https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/

    You may use Task/Triggered action feature if you would like to store value of cross-table calculation on table level.

    Here is an article:

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

    Hope this helps.

    Regards,

    vitalikssssss


  11. @kpcollier,

    You can use the following JS code if you decide to use a custom code.

    <script type="text/javascript">
    
    function calculate() {
    
        var subTotal = isNaN(parseFloat(document.getElementById("InsertRecordSubtotal").value)) ? 0 : parseFloat(document.getElementById("InsertRecordSubtotal").value);
        var markUp = isNaN(parseFloat(document.getElementById("InsertRecordMarkUp").value)) ? 0 : parseFloat(document.getElementById("InsertRecordMarkUp").value) ;
        var countyTax = isNaN(parseFloat(document.getElementById("InsertRecordCounty_Tax").value)) ? 0 : parseFloat(document.getElementById("InsertRecordCounty_Tax").value);
        var miscPerc = isNaN(parseFloat(document.getElementById("InsertRecordMisc_Percent").value)) ? 0 : parseFloat(document.getElementById("InsertRecordMisc_Percent").value);
        var freight = isNaN(parseFloat(document.getElementById("InsertRecordFreight_Total").value)) ? 0 : parseFloat(document.getElementById("InsertRecordFreight_Total").value);
    
    
        var markUpTotal = document.getElementById("InsertRecordMarkUp_Total").value = (subTotal) * (markUp);
    
        var countyTaxTotal = document.getElementById("InsertRecordCountyTax_Total").value = (subTotal) * (countyTax);
    
        var miscPercTotal = document.getElementById("InsertRecordMisc_Percent_Total").value = (subTotal) * (miscPerc);
    
        document.getElementById("cbParamVirtual1").value = (subTotal) + (markUpTotal) + (countyTaxTotal) + (miscPercTotal) + (freight);
     
     }
     
    setInterval(calculate, 1500);
    
    </script>

    Regards,

    vitalikssssss


  12. Hi @BFuchs

    9 hours ago, BFuchs said:

    So if there is no record yet, user will have to click twice, first on the link to open update DP and then on the link to open Submission DP?

    No, user will be routed automatically to the Submission Form.

    9 hours ago, BFuchs said:

    In addition of trying to use the least datapages possible.

    User does not have to click second time.

    9 hours ago, BFuchs said:

    My goal here is to have the user click it only once

    I doubt that it will be possible. You may customize Tabular report with inline insert, however it will require some sophisticated JS code to cover all possible scenarios.

    Regards,

    vitalikssssss


  13. On 12/19/2019 at 2:54 PM, roattw said:

    Very helpful.  May, What does your data entry page look like?  How can you set a time field (Date/time) where people only enter the time (ie the time they started or ended)?  Without getting a dateor using a calendar popup?

    This might help: https://howto.caspio.com/tech-tips-and-articles/common-customizations/separate-input-fields-for-datetime-parts/

    Regards,

    vitalikssssss


  14. Hi @AmyBelote,

    You are right, List_string datatype is not supported in advanced features like Calculated field, Triggered action or Tasks.

    There is a feature request in Caspio IdeaBox:  Link

    As a workaround, you may export/import your table with List - String field as into Text(255) field in order to have a string with comma delimited values. 

    Hope this helps.

    Regards,

    vitalikssssss

     

×
×
  • Create New...