Roderick Posted June 6, 2020 Report Share Posted June 6, 2020 I'm trying to trigger a calculated field contingent on a select2 field or a hidden calculated field and I can't make it work. This is what I have: Field1(Cascading Dropdown Field for value: Field_ID) (converted into a select2 element using $('select[name="InsertRecordField1"]').select2();) VirtualField1 (Calculated Field) (Using the following sql SELECT Field_Name FROM Table WHERE [@field:Field1] = Field_ID) The SQL doesn't notice the changes made to Field1 nor its initial value on page load. I tried using JavaScript and SQL to give Field1's value to a another hidden Virtual Field and trigger the SQL with the following code: <script> document.getElementById('caspioNote').onmousemove = function() {myFunction();}; function myFunction() { var i = document.getElementsByName('InsertRecordField1')[0].value; document.getElementsByName('cbParamVirtual2')[0].value = i; } </script> ------ SQL for VirtualField1: SELECT Field_Name FROM Table WHERE [@cbParamVirtual2] = Field_ID The JavaScript works fine but the SQL does not seem to notice the changes in VirtualField2 This happens to other cascading fields too when I use VirtualField2 as the Parent Field. How could I archive this? Thanks in advance Quote Link to comment Share on other sites More sharing options...
0 NailDyanC Posted August 15, 2020 Report Share Posted August 15, 2020 Hi Roderick, Can you please try to use this formula: SELECT Field_Name FROM Table WHERE '[@cbParamVirtual2]'= target.[@field:ID] Just get the "[@field:ID]" in the field picker of your Calculated Values- Formula field. Also, just make sure that the value of the "[@cbParamVirtual2]" is equal to your "[@field:ID]" for you to get your desired result. I hope that helps. Quote Link to comment Share on other sites More sharing options...
0 Barbie Posted January 1, 2021 Report Share Posted January 1, 2021 For more details about calculated fields you may check these links: https://howto.caspio.com/datapages/reports/advanced-reporting/calculations-in-forms-and-reports/https://howto.caspio.com/function-reference/ - Barbie Quote Link to comment Share on other sites More sharing options...
Question
Roderick
I'm trying to trigger a calculated field contingent on a select2 field or a hidden calculated field and I can't make it work.
This is what I have:
Field1(Cascading Dropdown Field for value: Field_ID) (converted into a select2 element using $('select[name="InsertRecordField1"]').select2();)
VirtualField1 (Calculated Field) (Using the following sql SELECT Field_Name FROM Table WHERE [@field:Field1] = Field_ID)
The SQL doesn't notice the changes made to Field1 nor its initial value on page load.
I tried using JavaScript and SQL to give Field1's value to a another hidden Virtual Field and trigger the SQL with the following code:
<script>
document.getElementById('caspioNote').onmousemove = function() {myFunction();};
function myFunction() {
var i = document.getElementsByName('InsertRecordField1')[0].value;
document.getElementsByName('cbParamVirtual2')[0].value = i;
}
</script>
------
SQL for VirtualField1:
SELECT Field_Name FROM Table WHERE [@cbParamVirtual2] = Field_ID
The JavaScript works fine but the SQL does not seem to notice the changes in VirtualField2
This happens to other cascading fields too when I use VirtualField2 as the Parent Field.
How could I archive this? Thanks in advance
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.