Jump to content

WatashiwaJin

Caspio Guru
  • Content Count

    116
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by WatashiwaJin


  1. 17 hours ago, NeoInJS said:

    Thank @WatashiwaJin. However, I would still like my users to be able to change the field. I want to see that field populated with the First day of the month when the DataPage loads.

    Hi @NeoInJS -- if that is the case then I suggest that you follow these steps:

    - Add a "Virtual field" that uses "Calculated value" as the form element and paste the formula:
     

    CONVERT(DATETIME, (CAST(Month(SysUTCDateTime()) AS VARCHAR) + "/01/" + CAST(Year(SysUTCDateTime()) AS VARCHAR)), 101)

    - You can also hide the Virtual field -> go to the advance option then check "Hide Field:
    image.png.c9bc0467af08bfcd8ca06891638251c4.png

    - Now, we are going to create a script that will get the value form the formula. For us to do that we need to add a "Header and Footer" -> then in the footer paste this code:
     

    <script type="text/javascript">
    document.addEventListener('DataPageReady', function (event) {
     
      var vrt = document.querySelector('[name*=cbParamVirtual1]');
      var date = document.querySelector('[name*=InsertRecordYOURDATEFIELD]');
     
      vrt.onchange = function() {
      date.value = this.value.substring(0,9);
      }
      });
    </script>

    - Make sure that you unchecked the "Enable HTML Editor" in the advance tab of the Footer.

    - After this process, your date field will get the first day of the month and it still can be editable :)

     

    For more details, check these article:

    https://howto.caspio.com/function-reference/

    https://howto.caspio.com/datapages/ajax-loading/

    I hope this helps :) 

    ~WatashiwaJin~


  2. Hi @FinTheHuman,

    If you want the result to be editable then you will need a custom script to do that, follow this process for the step:

    (1) Use a Virtual field to do the calculations of the formula provided earlier and insert a DATETIME field(to store the output of the formula)

    (2) then make the Virtual field hidden :

    image.png.e2abe891e5b57617354388f7b7899c95.png

    (3) Insert a Header & Footer -> and paste this code in the Footer part:

    <script type="text/javascript">
    document.addEventListener('DataPageReady', function (event) {
    
      var src = document.querySelector('[name*=cbParamVirtual1]');
      var dest = document.querySelector('[name*=InsertRecordDATE]');
    
      src.onchange = function() {
      dest.value = this.value.substring(0,9);
      }
      });
    </script>

    Important Note:

    - Make sure that you unchecked the "Enable HTML editor" in the advance option of the Footer.

    - Use the correct name value of your actual field in the script.

    - The "var src" is the SOURCE of the value(where the formula is located).

    - The "var dest" is the DESTINATION of the formula output (the editable Date field itself).

    - This process is working on my end. Feel free to test it out here: https://c1abv183.caspio.com/dp/482760009312d3d82a8949d4987e

     

    I hope this helps :) 

    ~WatashiwaJin~


  3. Hi @FinTheHuman,

    You can add new Virtual field and use "Calculated value" in the form element then paste this formula to get the next day excluding the weekend:

    CASE 
    
    WHEN ((DatePart(dw, GetUTCDate())) = 6)
    THEN (DateAdd(day, 3, GetUTCDate()))
    
    WHEN ((DatePart(dw, GetUTCDate())) = 7)
    THEN (DateAdd(day, 2, GetUTCDate()))
    
    ELSE (DateAdd(day, 1, GetUTCDate()))
    
    END

    I hope this helps :)

    ~WatashiwaJin~


  4. Hi @SteveT,

    As far as I understand, you want to have second/another search within the primary search. Basically, search again after in the filtered result.

    If that is what you want then I suggest that you follow these process:

     (1) Create a Submission form with Virtual field(s) *for your first search/filter -> check "OnExit" in the advance option and change the parameter name ->  then paste the next URL (the search and report DataPage):

    image.thumb.png.ef169700336a0016422f79e9a9f77347.png

    (2) Create a Search and Report DataPage then in the configuration of search field(s), received the parameter that is being passed.  Then follow the 2 scenarios below:

    Case 1 (Search with a different field):

    If the first search is to filter the initial result then you will do search again with a different field then do this process:

    image.png.0d405df21d6affe4aaee38a27084e9ff.png

    image.png.884e9a4ba996b0bde626c6a492acc9eb.png

    Case 2 (Search with the same field):

    If you will also search with the same field to get a result then do this process:

    image.thumb.png.42e5ce34ff939ba057f9b0c4742657f8.png

    image.png.ebb20bc6cb3a33ad826dcfbaded9e099.png

    Let me know if you have further questions.

    I hope this helps :) 

    ~WatashiwaJin~

     


  5. Hi @FinTheHuman - In addition for the earlier response, you can also use this formula to get the week number with the corresponding month via DataPage level:
     

    CASE 
    WHEN
    (DatePart(day, DateDiff(day, 0, [@field:DATE])/7 * 7)/7 + 1) = 1
    THEN 'Week 1 of ' + (DATENAME(month, [@field:DATE]))
    WHEN
    (DatePart(day, DateDiff(day, 0, [@field:DATE])/7 * 7)/7 + 1) = 2
    THEN 'Week 2 of ' + (DATENAME(month, [@field:DATE]))
    WHEN
    (DatePart(day, DateDiff(day, 0, [@field:DATE])/7 * 7)/7 + 1) = 3
    THEN 'Week 3 of ' + (DATENAME(month, [@field:DATE]))
    WHEN
    (DatePart(day, DateDiff(day, 0, [@field:DATE])/7 * 7)/7 + 1) = 4
    THEN 'Week 4 of ' + (DATENAME(month, [@field:DATE]))
    ELSE 'Week 5 of ' + (DATENAME(month, [@field:DATE]))
    END

    ~WatashiwaJin~

×
×
  • Create New...