Tags:
create new tag
view all tags

SID-01904: Need to fail page creation if submitted form is not unique

Status: Answered Answered TWiki version: 5.1.1 Perl version: 5.10.1
Category: CategoryForms Server OS: Oracle Solaris 10 8/11 s10x_u10wos_17b X86 Last update: 11 years ago

Hello, our lab's shift report system is built on TWiki. Some users are authorized to create a new Shift Report by filling a form that is embedded on the web's WebHome page using the RenderFormPlugin. They select a date and a shift (day, afternoon, graveyard, etc), and the RenderFormPlugin generates a page based on a template, with the submitted date and shift attached as form fields. The generated page is autonumbered.

Occasionally a duplicate shift report is created when two people try to start a shift report at roughly the same time, or if the second person just doesn't pay attention and doesn't realize that one is already created. We have scripts that process shift reports later, and they fail to run (intentionally) if a duplicate shift report is found. We have to do some manual cleanup, merging duplicates when this happens.

I'd like to know if it's possible to make TWiki fail to create a page if another page already exists that has the same values in the two form fields (date and shift). If we could prevent new duplicates from being created in the first place, we'd never have to clean up the mess they cause.

Thank you!

-- John Roberts - 2014-04-09

Discussion and Answer

We've chosen to get around this by modifying the processing script to allow duplicates and upload them to our archive server separately. No need to answer this.

-- John Roberts - 2014-04-09

There is no direct way to prevent a topic creation based on form field values.

Two options:

1. Test for unique topic name:

  • Create unique topic names, such as Report-2014-04-09-D (D for day shift).
  • Use Javascript to compose the topic name in a hidden form field from date input field and shift selector.
  • Use the onlynewtopic parameter to prevent creation of duplicate topics.

2. Test form field value of existing topics:

  • Add some Javascript to disable the form submit if any existing topic exists of user supplied date and shift
  • To do that you need to create a Javascript object containing the form data of all topics. Do that with a SEARCH, something like: var formData = { %SEARCH{ .... format=" '$topic': '$formfield(Date)-$formfield(Shift)' " separator=", " }% };

Please note that option 2 has a race condition: It takes time to fill out the report form. A second person can load the form before the first person submits it.

-- Peter Thoeny - 2014-04-09

Hi Peter,

Thanks for the update. In this case we've decided to modify the processing script and allow duplicate shift reports to exist. Now when somebody creates a duplicate, it's not our problem anymore smile

Cheers, John

-- John Roberts - 2014-04-11

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Need to fail page creation if submitted form is not unique
SupportCategory CategoryForms
TWiki version 5.1.1
Server OS Oracle Solaris 10 8/11 s10x_u10wos_17b X86
Web server Apache 2.0.22
Perl version 5.10.1
Browser & version Pale Moon 24.4.2
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2014-04-11 - JohnIRoberts
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.