Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Auto submit (if criteria are met) -> redirect new edit form

Questions related to using nuBuilder Forte.
Locked
pyro
Posts: 11
Joined: Wed Jan 17, 2018 7:06 pm

Auto submit (if criteria are met) -> redirect new edit form

Unread post by pyro »

Hi,

1. Check if field SN has 10 characters
2. If yes move check if string meets certain criteria (first to characters should be letters)
3. If string is ok auto safe form
4. open new blank form (copy some values from the last form, e.g Product)

basically I have an usb barcode scanner where I want to scan many products in a row. Therefore it would be very unconvertible to always need to click save -> go back -> open new foam
Edit form.PNG
I hope someone can point me in the right direction.

Thank you very much
You do not have the required permissions to view the files attached to this post.
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Auto submit (if criteria are met) -> redirect new edit f

Unread post by toms »

I'd attach an onchange handler to the SN field and there you check if the enterted string meets the criterias.
Then you call nuSaveAction(); to save the current record.
With nuCloneAction() you clone the record and in a function nuOnClone(), that will be run after the Clone action is done, you empty the SN field with $('#your_SN_field').val('');
Since the save action is executed asynchronously, you need to wait until the saving is finished before you clone the record. I haven't spotted an nuAfterSave() event though.
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Auto submit (if criteria are met) -> redirect new edit f

Unread post by admin »

pyro,

If I understand what you're trying to do correctly...

You should have a main Edit Form for Product, User, Comment etc.

And a Subform for Serial Numbers.

2 Tables...

1. One to keep Product/Batch Details.
2. One to keep all the SNs (a primary key, a foreign key (that links to the product/batch table) and a serial number field.

That way...

- You can add up to 1000 serial numbers in the Subform without opening another Form.
- You are not keeping duplicate info for every serial number.
- If you had to change the comment for a batch of 10 things, you'll only need to do it once.
- You won't be filling the database with redundant data.

That's what I'm thinking.

eg.
sn.PNG

Steven
You do not have the required permissions to view the files attached to this post.
pyro
Posts: 11
Joined: Wed Jan 17, 2018 7:06 pm

Re: Auto submit (if criteria are met) -> redirect new edit f

Unread post by pyro »

Hi,
thank you very much for your great support.

I could archive it with the following code

Code: Select all

function nuOnClone() {
     $('#sn_sn').val('');
     $('#sn_sn').focus();
}

function checkchange() {
if ($('#sn_sn').val().length != 10) {   
     alert('This is not a Serial Number');
     $('#sn_sn').val('');
     return;
}

nuSaveAction();
setTimeout(function(){ nuCloneAction(); }, 1000);

}
@steven thank you for the further explanation, i will implement it for my next (more complex) project
admin
Site Admin
Posts: 2814
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Auto submit (if criteria are met) -> redirect new edit f

Unread post by admin »

.
Locked