0

Submit button with required fields notification.

Hi, I have a very limited knowledge when it comes to writing scripts so please consider this when answering. I have form for managers where they have to fill up information about sales and production every day. There is about 20 fields in a form and all are required. I have found how to write it for one field but what if I have many? Looking for some simple solution when they click on submit button and if some required  fields are not filled it will show message which fields are not filled (or even message “fill up required fields” is enough) and it will prevent them from closing the form until everything is filled.

26 replies

null
    • Michal_Bor
    • 1 mth ago
    • Reported - view

     i have made one more button for another report, but has the same problem as with button for DAILY SALES, when i add at then the part to delete information from field, line 127 it shows problem. Any chance you could look please what I am doing wrong? I have used null or 0 according what you wrote before.

    let t := this;
    let xlf := urlDecode("%0A");
    let dateCheck := if Date = null then 1 else 0 end;
    let productsCheck := if PRODUCT = null then 1 else 0 end;
    let shopsCheck := if SHOP = null then 1 else 0 end;
    let employeesCheck := if NAME = null then 1 else 0 end;
    let preparedwhereCheck := if PREPARED = null then 1 else 0 end;
    let startCheck := if START = null then 1 else 0 end;
    let endCheck := if END = null then 1 else 0 end;
    let breakstartCheck := if 'BREAK START' = null then 1 else 0 end;
    let breakendCheck := if 'BREAK END' = null then 1 else 0 end;
    let break2startCheck := if 'BREAK 2 START' = null then
            1
        else
            0
        end;
    let break2endCheck := if 'BREAK 2 END' = null then 1 else 0 end;
    let break3startCheck := if 'BREAK 3 START' = null then
            1
        else
            0
        end;
    let break3endCheck := if 'BREAK 3 END' = null then 1 else 0 end;
    let kgpreparedCheck := if 'KG PREPARED' = null then 1 else 0 end;
    let itemspreparedCheck := if 'ITEMS PREPARED' = null then
            1
        else
            0
        end;
    let itemsrejectedCheck := if 'ITEMS REJECTED' = null then
            1
        else
            0
        end;
    let fieldCheck := [dateCheck, productsCheck, shopsCheck, employeesCheck, preparedwhereCheck, startCheck, endCheck, breakstartCheck, breakendCheck, break2startCheck, break2endCheck, break3startCheck, break3endCheck, kgpreparedCheck, itemspreparedCheck, itemsrejectedCheck];
    if sum(fieldCheck) = 0 then
        let newRec := (create 'HANGING PRODUCTION');
        newRec.(
            DATE := t.Date;
            PRODUCT := t.PRODUCT;
            SHOP := t.SHOP;
            NAME := t.NAME;
            'PREPARED WHERE' := t.PREPARED;
            START := t.START;
            END := t.END;
            'BREAK START' := t.'BREAK START';
            'BREAK END' := t.'BREAK END';
            'BREAK 2 START' := t.'BREAK 2 START';
            'BREAK 2 END' := t.'BREAK 2 END';
            'BREAK 3 START' := t.'BREAK 3 START';
            'BREAK 3 END' := t.'BREAK 3 END';
            'KG PREPARED' := t.'KG PREPARED';
            'ITEMS PREPARED' := t.'ITEMS PREPARED';
            'ITEMS REJECTED' := t.'ITEMS REJECTED'
        );
        alert("New Record Added")
    else
        alert("Please fill in the following fields:" +
        if item(fieldCheck, 0) = 1 then
            xlf + "DATE"
        end +
        " " +
        if item(fieldCheck, 1) = 1 then
            xlf + "PRODUCTS"
        end +
        " " +
        if item(fieldCheck, 2) = 1 then
            xlf + "SHOPS"
        end +
        "" +
        if item(fieldCheck, 3) = 1 then
            xlf + "NAME"
        end +
        "" +
        if item(fieldCheck, 4) = 1 then
            xlf + "PREPARED"
        end +
        "" +
        if item(fieldCheck, 5) = 1 then
            xlf + "START"
        end +
        "" +
        if item(fieldCheck, 6) = 1 then
            xlf + "END"
        end +
        "" +
        if item(fieldCheck, 7) = 1 then
            xlf + "BREAK START"
        end +
        "" +
        if item(fieldCheck, 8) = 1 then
            xlf + "BREAK END"
        end +
        "" +
        if item(fieldCheck, 9) = 1 then
            xlf + "BREAK 2 START"
        end +
        "" +
        if item(fieldCheck, 10) = 1 then
            xlf + "BREAK 2 END"
        end +
        "" +
        if item(fieldCheck, 11) = 1 then
            xlf + "BREAK 3 START"
        end +
        "" +
        if item(fieldCheck, 12) = 1 then
            xlf + "BREAK 3 END"
        end +
        "" +
        if item(fieldCheck, 13) = 1 then
            xlf + "KG PREPARED"
        end +
        "" +
        if item(fieldCheck, 14) = 1 then
            xlf + "ITEMS PREPARED"
        end +
        "" +
        if item(fieldCheck, 15) = 1 then
            xlf + "ITEMS REJECTED"
        end +
        "
    
        ")
    end
    
        Date := null;
        PRODUCT := 0;
        SHOP := 0;
        NAME := 0;
        PREPARED := null;
        START := null;
        END := null;
        'BREAK START' := null;
        'BREAK END' := null;
        'BREAK 2 START' := null;
        'BREAK 2 END' := null;
        'BREAK 3 START' := null;
        'BREAK 3 END' := null;
        'KG PREPARED' := null;
        'ITEMS PREPARED' := null;
        'ITEMS REJECTED' := null;
    
    end
    
      • Fred
      • 1 mth ago
      • Reported - view

        What errors are you getting?

      With such a long piece of code it is very easy to lose track of end statements.

      Line 125 needs a ";" to close out the if statement from line 36.

      Line 144 is, I think, an unnecessary end statement.

      On a side note, I see you have fields called Break 2 start/end and Break 3 start/end. The issue with duplicating fields that hold the same data is that you will find it very difficult to write code to search/filter/manipulate records based on these fields.

      May I suggest that you create a Break subtable that will keep track of all instances of breaks for the parent record. With a subtable and the count() command, you can quickly find parent records that only have 1 break, or more than 1 break. Compared to the other way you have to check for data in three or six different fields to be sure.

      In addition you can have fields that store break specific information.

Content aside

  • 1 mth agoLast active
  • 26Replies
  • 167Views
  • 4 Following