Jump to content
  • 0

SQL contingent on a Select2 field


Roderick

Question

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

  • 0

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.

 

 

Link to comment
Share on other sites

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...