MACRO sc_apl_conf() NOT WORKING

Since I have no help or response I’m posting it here because there seems to be something wrong either with this Macro or Scriptcase IDE. I tested this in every possible way and I cannot simply get this macro to work. I have had exactly the same problem some time ago. I could not resolve it for 2-3 weeks. I gave up for some time and moved on to another part of the project. At some point the same code I have had started working, despite I have not changes a single line of code. I do not know what is causing it but I cannot spend months on such simple thing.

The process is to simply call a FORM which

  1. adds a single record to the table (if it does not exists)
    OR
  2. modifies existing record if it does exist

Here is the code I use in the MENU

if ({sc_menu_item} == "item_1")
{
    $query1 = "SELECT UID, companyname FROM g_systemsettings WHERE UID=1";
    sc_select(dataset, $query1);

    if (false == {dataset})
        {
            // Record not found
            sc_alert("mode - NEW");
            sc_apl_conf ("m_g_config", "start", "new");

        }
    elseif ({dataset}->EOF)
        {
            // Record found
            sc_alert("mode - UPDATE");
            sc_apl_conf ("m_g_config", "update", "on");

        }
    else
        {
            // Error
            sc_alert("Unknown Error");
            
        }
}  

[ATTACH=CONFIG]n68713[/ATTACH]

none of the messages show up on the screen. I even went further and removed some code leaving only this:

if ({sc_menu_item} == "item_1")
{
             sc_alert("test");
            
        }

and the alert message does not show up!
I have another menu where similar code works (although it is not exactly the same).

I tried to remove temp files, _lib files, clear browser cache and cookies,…but nothing works.
I also run SC in Google Chrome, regenerated the whole project and run the App. The same result :frowning:

PS> Admin - please remove initial message fomr the general section. TNX

menu_item.png

I told you several times. You CAN’T stop a PHP process with an sc_alert, check macros doc to see where you can use it. This is the reason you don’t see the alert.

About the problem, you just have to use:
sc_apl_conf (“m_g_config”, “start”, “new”);

If you want to open in edit mode, just don’t call apl_conf, is not needed because is the default behaviour. apl_conf with update_mode, AFAIK, is just to “hide” the update button of a form.

Then, your code should be something like:

if ({sc_menu_item} == "item_1")
{
    $query1 = "SELECT UID, companyname FROM g_systemsettings WHERE UID=1";
    sc_select(dataset, $query1);

    if (false == {dataset})
        {
            // Record not found
            sc_apl_conf ("m_g_config", "start", "new");

        }
    else
        {
            // Error          
        }
}  

I move outside bugs subforum.

OK, Giu, I will try your suggestion and report back here. /Thanks
BTW. so what’s the best way to do some testing (i.e. I want to display a string or Var here) if you say sc_alert() would not work here ?
let’s say I want to display message in an /Error line - should sc_error_message(“Text”) - work ?

ARTHUR

For testing/debug I created a Little function to write on an html file to see var values, but I’m not in front of a PC

Damn phone. I will share in my morning

http://scriptcasers.com/simple-way-debug-variables-scriptcase/

It is still not working. No matter what I do the form opens up in INSERT mode. I’m able to add first record (if none exists) but the form does this by going into INSERT mode. Then each SAVE causes duplicate record error or adds new record. There is no way to edit existing record. I tried to read the record nr.1 in “OnLoad” even but doesn’t help as well. By looking at the code in the forst post there seem to be only 2 posibilities.
1- the line: [B]if (false == {dataset}) for some reason is always TURE
2. macro is not working (at least the EDIT mode is not)

I wonder if somebody could confirm if this works:

 sc_apl_conf ("myapp", "update", "on");

[/B]

I REALLY WANT NETMAKE TO IMPLEMENT SOME FORM MODE INDICATOR (variable) THAT WE CAN EASILY TEST WHILE RUNNING APPS

Giu - I posted this into BUGS. You moved this post out of that section. For over 2 weeks I keep trying to get some help on this and no response. I’m getting really upset about all this. Why don’t you send a sample here so we can see this works. If there is no example I see it as BUG! (unless somebody confirm it works). I will extract the table an 2 Apps necessary to test it and post it back here.

Sorry Arthur, I was very busy.

1- the line: if (false == {dataset}) for some reason is always TURE

I can’t help here without debugging.

2. macro is not working (at least the EDIT mode is not)

Form has not any edit mode. By default, a form is in edit mode always.

Well, I moved outside Bug subforum until confirmed if it’s really a bug or not (because all tests was succesfully)
I tried a lot apl_conf without any issues

I move again into bugs, to be considered by @John_L_Santos or @Cavadinha but because you set the form to be in ADD mode, is the expected behaviour IMHO. The problem is the lack of a way to exit from this mode.

Said that, apl_conf is not needed for what you need.

[ATTACH=CONFIG]n68901[/ATTACH] [ATTACH=CONFIG]n68902[/ATTACH] [ATTACH=CONFIG]n68903[/ATTACH]

image_2927.png

image_2928.png

image_2929.png

Giu thanks for your time.

Your suggestion does not work. I tried it already some time ago. The problem is that when I use your method on return from the form my menu opens twice (or I should say kinda on top of another). The effect is that I have two vertical menus sitting one under another. The problem here is that there is no way to add _parent attribute (where you red arrow is). I can use this attribute in “OnValidate” event and that solves this problem.
Forget about the RETURN issue because I got this managed.

The issue with calling single form is still unresolved. I just got an email from NetMake but they of course did not read my info carefully claiming it is working. The problem is that they call this macro from “OnLoad” even, and they use

sc_apl_config("myapp", "insert", "off")

when I try this I get error on on opening/loading the record (ERROR: No records found").

If your statement (the form has no edit mode" is TRUE() then why they have macro ?

sc_apl_conf ("myapp", "update", "on");

the whole concept with this is f…up! If they have used global Var’s like I suggested it would be so much easier to manage all forms.

HERE ARE THE STEPS TO REPRODUCE THE ISSUE

  1. Create a table with PK (i.e UID(Int). This table will always have only one record.
  2. Create vertical menu and assign an item (i.e SETTINGS)
  3. Create a form to edit table (from step 1)
  4. Call this form from the menu by using “OnExecute” event
  5. In case the record exists the form should open in EDIT mode, if it doesn’t exist it should open in INSERT mode.

I sent you in Skype some apps (is an apps export, not a project, but import on a new project to avoid name conflicts), and an SQL to recreate the table. It works for me (if I understand the problem) adapt to your needs and report back to me what’s not working. WHERE is hardcoded, take into consideration to see whats the next ID value for your testing.

when I try this I get error on on opening/loading the record (ERROR: No records found").

because this disable the insertion on the form. It’s the same if you move your insert button out of toolbar. Form will not enter on Insert mode if no records found.

If your statement (the form has no edit mode" is TRUE() then why they have macro ?
HTML Code:
sc_apl_conf (“myapp”, “update”, “on”);

Because this disable update button. Difference with sc_button_display, is that you can apply modifications on forms based on roles with apl_conf, from a login FORM for example. sc_button_display should be used in every app directly.

HERE ARE THE STEPS TO REPRODUCE THE ISSUE

  1. Create a table with PK (i.e UID(Int). This table will always have only one record.
  2. Create vertical menu and assign an item (i.e SETTINGS)
  3. Create a form to edit table (from step 1)
  4. Call this form from the menu by using “OnExecute” event
  5. In case the record exists the form should open in EDIT mode, if it doesn’t exist it should open in INSERT mode.

This is the example I created and send you by skype (don’t have your email).

OK, so if I understand you correctly this macro does not change a form mode but rather enable/disable buttons on the form - is that correct ?

Yes and no. Forms has 2 states. Normal (for updates) or inserts. By default, a form always open a record for update. If table has no records under SQL criteria, open directly for new record.
There are situations where you don’t have records but you don’t want to enter on insert mode either, and there are situations where you have records but you want to force to enter new record.

“update”, “on”, I guess, hide update button, is the same that disable update mode (because there is no button, you can’t save).
“insert”, “off” hide insert button, is the same that disable insert mode (because there is no button, you can’t insert).
“start”, “new”, says to the form to go into mode for enter new records, but, if you have an “insert”, “off”, because insert is disabled, will not enter on insert mode.

Move update or insert buttons outside toolbar, does the same. Difference? Imagine you want to disable update button for some specifics forms. Hiding buttons does the job, but you have to write your logic in every app. with apl_conf you can iterate over affected apps with your logic from one place, and will affect to complete project over the session.

Control of all of this could be better, of course, but right now works as is and more or less makes sense. For this reason, IMHO, is more a suggestion than a bug, but maybe, I miss something in my tests.

This was my research, maybe something is wrong, I did a lot of tests, and don’t remember exactly every situation/combination

All this has very erratic logic and the macros should be able to change/set FORM mode (not buttons). Anyway the form is still freaking up . I received a video from NM showing it is working but instead using my Apps they created a new form. I think I used batch creation tool for mine and they used single App. Not sure if this makes difference but I have already seen the apps fomr wizard not exactly the same created from templates. Sometimes App created with one method has a problem while recreated with another method it doesn’t. Not sure what’s causing it but this happened to me al least several times in recent 2-3 years.
It is not the first time I see something not working, then when I re-create the same App it works. I just asked them to precisely use the App I have sent to verify if it works on their end. I’m leaving for a trip for few days , will check back on Tuesday. TNX

OK, finally after exchanging several messages with NetMake bug team I realized why this was not working. All due to totally poor documentation. Basically when I removed the INSERT button or UPDATE button form is not working anymore in INSERT or UPDATE mode. This is rather very poor implementation. I would like to see the buttons being independent on the mode.

The main issue came from the fact that nowhere in the macro help is explained that sc_apl_conf() applies only to form buttons. Thank you Giu for clarification.

modified code looks like this

if ({sc_menu_item} == "item_50")
{    
    $query1 = ("SELECT UID, companyname FROM g_systemsettings WHERE UID=1");
    sc_lookup(rs, $query1);
    
    if (isset({rs[0][0]}))     // Row found
    {
        sc_apl_conf ("m_g_config", "update", "on");
        sc_apl_conf ("m_g_config", "insert", "off");
        sc_apl_conf ("m_g_config", "delete", "off");
    }
            else     // No row found
    {
        sc_apl_conf ("m_g_config", "update", "off");
        sc_apl_conf ("m_g_config", "start", "new");
        sc_apl_conf ("m_g_config", "delete", "off");
    }
}

Anyway for some reason the old form did not work even after proper changess. I recreated the form from the wizard and modified the macro and it seems to work now, however there is one other issue.
Because the table is a single record table it has PK but the field (in this case UID(Int) - is not autonumbered. I tried to apply the UID=1 on the form EDIT FIELDS screen but it has no effect for some reason. So again I’m not sure if we are dealing with BUG or there is something else missing which I do not understand.

Looking into help I realized there is option which is undocumented and this needs to be addressed ! <------------------------------ THIS LINE IS FOR NETMAKE (to update HELP!

Anybody knows what these checkboxes are for ? [ATTACH=CONFIG]n69092[/ATTACH]

When I change the settings to AUTOINCREMENT then it seems to work. IT should work with manual assignment BUT IT DOESN’T.

EditFields_NotWorking.png

OK, so finally I have found what is causing the issue! IT took me 2 weeks to figure out. IT IS A BUG !

When I remove the navigation buttons from the bottom toolbar I get the error message

[ATTACH=CONFIG]n69112[/ATTACH]

this is despite the record DOES EXIST IN THE TABLE
[ATTACH=CONFIG]n69113[/ATTACH]

When I add NEXT/PREVIOUS to the Toolbar the error message is gone. This is obviously not normal because:

  1. I do not want Net/Previous for single record
  2. Record exists in a table while SC shows “No records” message

[ATTACH=CONFIG]n69114[/ATTACH]

here is the form with the navigation buttons WHICH I DO NOT WANT !

[ATTACH=CONFIG]n69116[/ATTACH]

SingleRecordForm_bug02.png

SingleRecordForm_bug01.jpg

SingleRecordForm_bug04.png

SingleRecordForm_bug03.png

SingleRecordForm_bug05.png

[SIZE=24px]I WOULD LIKE TO SEE THE RESPONSE FROM NETMAKE HERE ![/SIZE]

1 Like