How to only allow users to edit new records

Forum to discuss the Web client version of Servoy.

How to only allow users to edit new records

Postby Westy » Thu Mar 02, 2006 4:21 pm

For a phone log, what is a good way to only allow users to edit new records?
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby ebrandt » Thu Mar 02, 2006 5:53 pm

I had an issue with editing records in a portal, because I needed run a method onDataChange to disable visability of a specific field in the row.

What I did was to create a hidden tab panel to display just the one record that was selected in the new form.

So if the record is new, then the hidden tab panel or FID opens to allow editing.

Not sure if there is a easier method, or even if thats what you are trying to accomplish, but it works for me.

Erich
ebrandt
 
Posts: 590
Joined: Tue Mar 30, 2004 6:54 pm
Location: largo, fl

Postby automazione » Thu Mar 02, 2006 7:37 pm

just a quick suggestion.. you can use the readOnly property associated to the form. I play quite often with that... put it on false when adding a new record... set it to true when browsing the old records...
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy

Postby Westy » Thu Mar 02, 2006 11:20 pm

automazione wrote:just a quick suggestion.. you can use the readOnly property associated to the form. I play quite often with that... put it on false when adding a new record... set it to true when browsing the old records...

Interesting. How can I set the readOnly property associated with a form? Have you tried it with webclient?
Westy
 
Posts: 852
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Postby swingman » Fri Mar 03, 2006 10:29 am

Hi,

It is also possible to do this kind of thing at the database level:

I use a numeric field called document_locked to keep invoices locked
document_locked == 0, editable
document_locked == 1, locked
document_locked == 2, to unlock locked records :-)

Then I have a trigger function the PostgreSQL database

Code: Select all
CREATE TRIGGER trg_acc_documents_lock_check
  BEFORE UPDATE OR DELETE
  ON acc_documents
  FOR EACH ROW
  EXECUTE PROCEDURE acc_document_lock_check();


calling

Code: Select all
CREATE OR REPLACE FUNCTION acc_document_lock_check()
  RETURNS "trigger" AS
$BODY$
BEGIN
    IF TG_OP = $$UPDATE$$ THEN
       IF NEW.document_locked = 2 THEN
          NEW.document_locked:= NULL;
            RETURN new;
       ELSEIF OLD.document_locked = 1 THEN
          RAISE EXCEPTION $$Cannot update a locked document number %$$,OLD.document_number;
       ELSE
          RETURN new;
        END IF;
   END IF;
    IF TG_OP = $$DELETE$$ THEN
       IF OLD.document_locked = 1 THEN
          RAISE EXCEPTION $$Cannot delete a locked document number %$$,OLD.document_number;
       ELSE
          RETURN old;
        END IF;
   END IF;
END
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
Christian Batchelor
Certified Servoy Developer
Batchelor Associates Ltd, London, UK
http://www.batchelorassociates.co.uk

http://www.postgresql.org - The world's most advanced open source database.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Postby automazione » Fri Mar 03, 2006 10:54 am

Westy wrote:Interesting. How can I set the readOnly property associated with a form?

controller.readOnly = true;
Westy wrote:Have you tried it with webclient?

just try it.. but problably it does not yet work
Enrico Arata
Servoy Italia
automazione
 
Posts: 366
Joined: Thu Apr 24, 2003 11:37 am
Location: Torino, Italy

Postby IT2Be » Fri Mar 03, 2006 1:25 pm

You can also use the Servoy Security system where you can exclude/include groups on editing, visibility etc. On a form/element level.

Really fantastic!!!
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 7 guests

cron