Javascript question re. File Upload Widget

Use this board to ask questions or have discussions with other Genie users.
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Re: Javascript question re. File Upload Widget

Post by Wayne C. »

Sorry about that. In the beginning, to get the whole process clicking, I just used the 7 digit portion. But the powers that be want the folder to be named using the entire 12 characters.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Javascript question re. File Upload Widget

Post by Scott Klement »

Ah, sorry this took so long... here's my suggestion.

So that you don't have to do this in the screen itself every time you want to use it, I would suggest just adding some functions to your Genie skin's custom.js file. For example, maybe you'd want to add routines like this... just open up the custom.js file and add these on to the end.

Code: Select all

function zeroPad(num, digits) {
    var str = num + "";   // force to a string
    while(str.length < digits){
        str='0'+str;
    }
    return str;
}

function getFormattedPro(fld1, fld2, fld3) {
    return get(fld1) 
         + zeroPad(get(fld2), 7) 
         + zeroPad(get(fld3), 2);
}
These routines are similar to RPG subprocedures. They are routines you can call from JavaScript, pass parameters to them, and get back a result. The zeroPad() routine accepts a number whre the leading zeros have been supressed, and it pads it out with zeroes to the length you specify. The getFormattedPro() routine uses the zeroPad routine to format the Pro# that you mentioned. (Assuming I understood correctly, anyway.) You pass it the screen IDs of 3 fields, and it builds the formatted Pro#.

Once these are in your custom.js file, you'll need to click the "Refresh" button in Genie to reload and get the updated JAvaScript. (Or, clear the cache, then close the browser, re-open and run Genie again... this will also work. Or just wait until the cache reloads itself... but that could be time consuming if you are testing your work.)

Now that you have the new functions, change the directory in the Upload widget properties to something like this:

Code: Select all

script: getFormattedPro("I_3_15", "I_3_19", "I_3_27");
(Replace the I_3_xxx fields that I used above with the 3 fields you have on your screens for the parts of the Pro#)

Hope that makes sense...
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Re: Javascript question re. File Upload Widget

Post by Wayne C. »

I'm eternally grateful for your time and the routines. They look pretty understandable. I am going to work with them today and let you know how it works out. Thanks again Scott!
Wayne C.
Experienced User
Posts: 139
Joined: Mon Aug 16, 2010 12:04 pm
First Name: Wayne
Last Name: Colasinski
Company Name: Sofworx / Tantara Transport
Contact:

Re: Javascript question re. File Upload Widget

Post by Wayne C. »

Thanks Scott. The routines work like a charm.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 3 guests