NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: terryd on August 08, 2014, 08:53:53 AM
-
I've got a parent record and add child records to it. I want to limit the number of records per parent to 6, after which I would like to hide the insert button. What would you suggest as the best method?
-
Hi,
In the set queue record embed, increase a session value with one for every record you process.
Then put a hide condition for the insert button.
Correct me if i'm wrong.
Cheers,
Rene Simons
-
Hi Rene
I think this would work if the user was capturing all the child records at the same time but if the user could add some records now and come back at a later date to add more then there would be a problem.
My current solution is to create a small source procedure which does a count of the number of records linked to the active parent and if it is 6 then return a value of 1. I would call this procedure from the PreInsert routine.I could then do an nt-alert message if the value is 1 advising the user that the limitation has been reached.
If this makes sense what would I do at this point to gracefully close the procedure and return to the parent browse?
It seems I should just 'do CancelForm'
Any comments?
-
OK my solution works up to the point of sending the nt-alert message.\Calling CancelForm does nothing.
What would I do at this point to close the form and display the parent browse.
I am still trying to get the insert button to hide if the records in the parent are greater than 5 but no luck so far. This would be a more elegant solution than going into the form and then be told that the insert cannot continue.
-
Hi,
I was under the impression that the child records were being showed in a child browse.
Hence my suggestion.
Rene
-
Hi Rene
I didn't ignore your suggestion, I appreciated it, but I found that it only works up to a point in the child browse.
The problem from what I can see in the generated code is that changing parents although it calls the GenerateUpdateButtonsBelow routine does not in fact regenerate the buttons. The loc:stage at this point is not set to Generate Updates and so nothing in that routine is processed.
So what happens is even though I count the number of child records correctly and set the condition in the insert button the Insert button will be hidden or unhidden based on the number of child records in the highlighted parent record when first running the parent browse procedure.
-
Bruce
Any advice?
I think the restricting the browse is a problem but what can I do within the form. Currently I get the alert message advising that the limit has been reached but there is nothing to stop the user from clicking Ok and then continuing the capture. I can stop them at saving but I would rather return them to the browse immediately after the message.
-
maybe you should be asking why you want to limit the records to 6, when the users clearly want to enter more.....
there are probably ways to limit it from the browse - I guess by disabling the insert button - something like (in 8.25);
p_web.ntBrowse(loc:divname,'disableButton','''[data-do="insert"]''')
you could do this at the point when you decide to allow, or not allow, the insert button.
Cheers
Bruce
-
Bruce
I do know why I want to disable the Insert. The browse is intended to populate a waybill which has a limit of 6 lines. We do not want to create multiple page waybills, hence the restriction requirement. The user want to enter more because he doesn't think and since he's out there in the wild I would rather not have to remove the extra records because he could do something that he was not supposed to do.
-
the other option is you just pre-populate 6 blank records they can use and remove the insert button.
-
Hallo Bruce,
>p_web.ntBrowse(loc:divname,'disableButton','''[data-do="insert"]''')
This code works ok but how to manage if you have parent - child browse on the same memory form and 2 insert buttons?
Now when I execute this code it will disable both insert buttons..
How can I disable only the insert button I want?
Thank you,
Robert