Page 2 of 2

Re: Javascript question re. File Upload Widget

Posted: Fri Jul 25, 2014 6:44 pm
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.

Re: Javascript question re. File Upload Widget

Posted: Fri Aug 01, 2014 6:02 pm
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...

Re: Javascript question re. File Upload Widget

Posted: Mon Aug 04, 2014 12:39 pm
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!

Re: Javascript question re. File Upload Widget

Posted: Tue Aug 05, 2014 11:32 am
by Wayne C.
Thanks Scott. The routines work like a charm.