Jump to content

Update Field table


Recommended Posts

I have a single update form that receives a parameter in a Virtual field. I need to update an existing field (FulfilledQtyDiaper) by adding its current value and the value of the virtual field. I have this script in my Footer but it is not working.

 

<br />
<SCRIPT LANGUAGE="JavaScript">
 
function UpdateQty()
{
       var d = parseInt(document.getElementById("cbParamVirtual1").value);
 
        var newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value);
   
        document.getElementById("EditRecordFulfilledQtyDiaper").value  = newd;
       
}
 document.getElementById("caspioform").onsubmit= UpdateQty;
 
</SCRIPT>
Link to comment
Share on other sites

Hi NeoInJS,

I tried the script on my end and it works out-of-the-box. Please check the following to ensure that the script works on your end:

  1. The FulfilledQtyDiaper table field must be a Number.
  2. On the Single Record Update DataPage, the FulfilledQtyDiaper must be displayed as a Text Field. You can check this setting in the Standard tab of the Configure Fields screen, under General Options  > Form Elements.

Hope this helps.

Link to comment
Share on other sites

  • 7 years later...

Hello @chthorne,

The 'onsubmit' event doesn`t work now, please use the 'BeforeFormSubmit' event instead:

<script>
document.addEventListener('BeforeFormSubmit', function (event) {
        const d = parseInt(document.getElementById("cbParamVirtual1").value);
        const newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value); 
        document.getElementById("EditRecordFulfilledQtyDiaper").value  = newd;
});
</script>

If you need further assistance please provide more details about your use case. 

In the initial question in this thread Virtual field receives a parameter. On your screenshot, it passes a value as parameter. 

In the code, the values are converted to integers. Perhaps, you have numbers that include decimal palaces so the values should be converted with parseFloat() and not with parseInt().

Link to comment
Share on other sites

Hello,

I made it to work by using BeforeFormSubmit event instead. The above code looks like the following with that modification: 

 

<script>
 
function UpdateQty()
{
       var d = parseInt(document.getElementById("cbParamVirtual1").value);
 
        var newd = d + parseInt(document.getElementById("EditRecordFulfilledQtyDiaper").value);
   
        document.getElementById("EditRecordFulfilledQtyDiaper").value  = newd;
       
}
document.addEventListener('BeforeFormSubmit', UpdateQty);
</script>

 

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