Jump to content
  • 0

Programatically populate a Cascading Dropdown search field




I am new on Caspio.

I have an application that has Users and Administrators.

Users may only view details for that user only.

Administrators may view all details of users that they responsible for.

I have a datapage report to print user details.

If the data page report is accessed by an Administrator, I pass a parameter with value '4',  for the data page to allow Admin to select users using the Cascading Dropdown. This works perfectly.

I want to use the same data page report even for users to see their details.  When a user accesses this data page, I pass a parameter of '7' as initially I wanted to use the on load functionality to also pass the User ID, so that user may only see their details only.  The Cascading Dropdown does not allow the on load functionality.

I want to populate the passed user Id parameter to the User Id search field.

On further reading I can do this in the footer with code that looks like the below.

The @P_MB_Role is the parameter to indicate whether an Admin or User is accessing the report.

The MemberContr_MB_SysID is the search field for the User ID with the Cascading Dropdown.

The @P_MB_SysID is the parameter with the User Id

May someone please help on how to code the below correctly, so that the passed parameter @P_MB_SysID value is populated/moved to MemberContr_MB_SysID so that the 'Search' can search on the correct User ID.

  document.addEventListener('BeforeFormSubmit', function(event) {

    if ("[@P_MB_Role]" == "7"){

      let MemberContr_MB_SysID = [@P_MB_SysID];

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0


In the Cascading Dropdown tab there is an option to limit the values that users can see based on the authentication.

Maybe you could create a lookup table with the information that each role can access. I use a similar solution in my application.

It is explained here https://howto.caspio.com/authentications-and-connections/authentication/record-level-security/filter-lookup-dropdown-or-listbox-based-on-user-or-role/

Another simple solution would be to use Rules. You can create a Virtual field to get the Role from authentication and set it to Hidden, then using Rules you can hide sections based on that authentication and use different cascading dropdowns each with different lookup tables.

Regarding the code, if I understand correctly you want to put the @P_MB_SysID in the MemberContr_MB_SysID search field using code. Something similar to this should work:

  var IdField = document.getElementsByName("Value1_1")[0]
  document.addEventListener('BeforeFormSubmit', function(event) {
    if ("[@P_MB_Role]" == "7"){
       IdField.value = [@P_MB_SysID]

You will have to change the "Value1_1" to match your search field position, you can also check which name the field has using the preview the page and inspect with Google dev tools the element to find the name="" attribute.


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.

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.

  • Create New...