Jump to content

Is there a way to prevent the user in adding a records base on field?


Recommended Posts

I have two tables and two tabular reports.

Tbl_Customer and Tbl_Projects


In the table customer this is where I set the limit field in which the user can only add a record base on this limit
image.png.ff04024ff0868401ed820ecdbcbf025b.png

This is what it looks like in the tabular page.
image.thumb.png.df3e75d13bff736899e9e2274b7ce5bd.png
Now when I click mark it would bring me to another tabular page where the user can inline add but I want them to be able to add only base on the limit for example in the screenshot Mark has only "1" limit I want to limit mark to be able to only post 1 record.

image.thumb.png.cf239c6d72f9dc0352c6d33cbdc6213d.png

Any thoughts about this? 

image.png

Link to comment
Share on other sites

Hi,

Since you are already passing parameters to view the customer projects via tabular report you can also pass the limit parameter.
https://howto.caspio.com/parameters/passing-parameters/

Example
image.png.a67cdc0ac7c69be0e736575ef2ee2516.png

Now on your tabular report you can hide the in-line add table-row by using this simple CSS and Javascript.
CSS 
<style id="dynamic-styles">
  /* Initial styles here */
</style>

JS:
 

<script>
  var lidValue = parseInt([@lid]); // Assuming [@lid] returns a number
  var rowIndexToHide = lidValue + 2;

  var styleTag = document.getElementById("dynamic-styles");

  if (styleTag) {
    styleTag.innerHTML += `
      .cbResultSetDataRow:nth-child(${rowIndexToHide}) {
        display: none;
      }
    `;
  }
</script>



what it would do is it would hide the rows of the inline add if it's already in the limit.

Hope this helps!


 

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

You may want to consider adding a formula field that adds +2 to the value of the Limit field for the row of the Header in the DataPage and the Inline Insert count. 

image.thumb.png.b4afa43c723f5f17ed7898cbad6a27db.png

And then on the Projects DataPage, you can just add a code to the Header for counting the rows and the field Limit value. The [@FLimit] is the parameter name for the LimitFormula field on the table that you created on the Customers table. 

image.png.88fe10bab95d636b9b44194953dfc90d.png

I hope it 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
Reply to this topic...

×   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...