Skip to main content
Participant
September 26, 2024
Answered

Dynamic Stamp JavaScript - Help

  • September 26, 2024
  • 1 reply
  • 1239 views

Hello,

i have a problem with my JavaScript.
I Created a Stamp witth 11 Fields, which have to be Filled see here:

My Problem is now that it works only for the first 9 Fields(var name str1...str11 in Code)
I just noticed that it only works vor all str1-str9 if i go higher with 2 digits str10 it dont works anymore...
Any idea how i can solve it to fill more then just 9 Fields?

Great Thanks.

This is how my pop-up window looks like:

 

After entered the Data:



Here is my Code:

var FormRouting = {
    return: 'cancel',
    DoDialog: function() {
        return app.execDialog(this);
    },

    str1: '',
    str2: '',
    str3: '',
    str4: '',
    str5: '',
    str6: '',
    str7: '',
    str8: '',
    str9: '',
    str10: '',
    str11: '',
    
    initialize: function(dialog) {
        var dlgInit = {
            str1: this.str1,
            str2: this.str2,
            str3: this.str3,
            str4: this.str4,
            str5: this.str5,
            str6: this.str6,
            str7: this.str7,
            str8: this.str8,
            str9: this.str9,
            str0: this.str10,
            str0: this.str11,
        };

        dialog.load(dlgInit);
    },

    commit: function(dialog) {
        var oRslt = dialog.store();
        if (oRslt) {
            this.str1 = oRslt['str1'] || '';
            this.str2 = oRslt['str2'] || '';
            this.str3 = oRslt['str3'] || '';
            this.str4 = oRslt['str4'] || '';
            this.str5 = oRslt['str5'] || '';
            this.str6 = oRslt['str6'] || '';
            this.str7 = oRslt['str7'] || '';
            this.str8 = oRslt['str8'] || '';
            this.str9 = oRslt['str9'] || '';
            this.str10 = oRslt['str10'] || '';
            this.str11 = oRslt['str11'] || '';
        }
    },
    
    description: {
        titlename: "Kontierung", align_children: "align_left", width: 500, height: 400, elements:
        [
            {   // Text Fields
                type: "cluster", name: "Data Entry", align_children: "align_left", elements:
                [
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "MD"
                            },
                            {
                                item_id: "str1", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "Kreditor"
                            },
                            {
                                item_id: "str2", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "SachkontoRow1"
                            },
                            {
                                item_id: "str3", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "SachkontoRow2"
                            },
                            {
                                item_id: "str4", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "SachkontoRow3"
                            },
                            {
                                item_id: "str5", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "NettoBetragRow1"
                            },
                            {
                                item_id: "str6", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "NettoBetragRow2"
                            },
                            {
                                item_id: "str7", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "NettoBetragRow3"
                            },
                            {
                                item_id: "str8", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "OPKostenstelleRow1"
                            },
                            {
                                item_id: "str9", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "OPKostenstelleRow2"
                            },
                            {
                                item_id: "str10", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                    {
                        type: "view", align_children: "align_row", elements:
                        [
                            {
                                type: "static_text", name: "OPKostenstelleRow2"
                            },
                            {
                                item_id: "str11", type: "edit_text", alignment: "align_fill", width: 400, height: 20
                            }
                        ]
                    },
                ]
            },
            {
                alignment: "align_right", 
                type: "ok_cancel",
                ok_name: "OK",
                cancel_name: "Cancel"
            }
        ],
    },
};

if (event.source.forReal && event.source.stampName == "#Abrechnung") {
    if ('ok' == FormRouting.DoDialog()) {
        // String fields
        this.getField('MD').value = FormRouting.str1;
        this.getField('Kreditor').value = FormRouting.str2;
        this.getField('SachkontoRow1').value = FormRouting.str3;
        this.getField('SachkontoRow2').value = FormRouting.str4;
        this.getField('SachkontoRow3').value = FormRouting.str5;
        this.getField('NettoBetragRow1').value = FormRouting.str6;
        this.getField('NettoBetragRow2').value = FormRouting.str7;
        this.getField('NettoBetragRow3').value = FormRouting.str8;
        this.getField('OPKostenstelleRow1').value = FormRouting.str9;
        this.getField('OPKostenstelleRow2').value = FormRouting.str10;
        this.getField('OPKostenstelleRow2').value = FormRouting.str11;
    }
}





This topic has been closed for replies.
Correct answer Bernd Alheit

item_id allows only 4 characters.

1 reply

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
September 26, 2024

item_id allows only 4 characters.

Participant
September 26, 2024

Thanks for that info.

i just changed them to 4 in my code.... but it then just takes the first 10.... not the last one:

md01: '',
    kred: '',
    sko1: '',
    sko2: '',
    sko3: '',
    nbt1: '',
    nbt2: '',
    nbt3: '',
    kst1: '',
    kst2: '',
    kst3: '',

 See image:

Is it somehow limited to max. 10 ids or smt???
when i try to use more then 10 the last ones stays empty....

PDF Automation Station
Community Expert
Community Expert
September 26, 2024

No, it is not limited to 10.  Did you change the id's throughout your code, whereever they appear?