Migrating Form to SCL
 

Migrating Form to SCL

4 posts, 1 answered
  1. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    30 Jan 2019
    Link to this post
    The form we are trying to migrate to the SCL does the following;
    1. It opens with 5 fields enabled for input.
    2. The user enters info into these fields.
    3. The user clicks save and we save to the DB.
    4. The form is cleared and ready for next entry.

    There is no navigation, updating existing records or deleting existing records. All the user does it enter info and click save which creates a new record in DB.

    What we have done so;

    Created a BE. 

    We have a SmartWindow that contains a smarttoolbar, business entity adapter and a smartviewer.

    When the form opens it shows the first record in the table after calling RetrieveData. If I do not call RetrieveData then the toolbar does not function. Is there a way to not have the first record displayed?

    I noticed there is "SaveMode" on the viewer which appears to put the viewer in update automatically where the fields are enabled. I am wondering if there is something similar to put the viewer in "add" mode? I know I can code a call to addrecord but was checking if there is a better way.

    I am thinking maybe the best thing to do is not have bound controls and just use InvokeMethod to call a METHOD in the BE that will do the create.



  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    Answered
    30 Jan 2019 in reply to Roger Blanchard
    Link to this post
    We don't have an auto-add mode or something like this. 

    I personally would have the tendency to implement this using a DatasetModel instead of an invoke method. All you're doing is to create new records with given values. There's no need to use an invokable method for that purpose. 

    DEFINE VARIABLE oCustomer AS CustomerDatasetModel NO-UNDO. 
    oCustomer = NEW CustomerDatasetModel () .

    oCustomer:TrackingChanges = TRUE.
    oCustomer:Customer:Create().
    oCustomer:Customer:Name = "Roger".
    oCustomer:SaveChanges ().
  3. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    30 Jan 2019 in reply to Mike Fechner
    Link to this post
    Okay, thanks. I will go with that.
  4. Roger Blanchard
    Roger Blanchard avatar
    413 posts
    Registered:
    29 Jun 2018
    30 Jan 2019 in reply to Mike Fechner
    Link to this post
    Mike,

    Thanks for the guidance. This does what I need. I was battling on writing code to override default handling of adapter/viewer.

    Thanks again.
4 posts, 1 answered