I have an Online form, a log on screen, with a bound screen element, an email field (textbox), where I populate the initial value from a local DB, i.e. the local DB “remembers” the users email address if a checkbox is checked. That part all works, the email address on the log on screen is populated from the local DB.
Here’s the DDS for the email address (EMAILADR) on my formview :
A 10 60HTML('<<EMAILADR>>
A Type : Textbox
A DataType : Email
A ShowClearButton : True
A Layout.Cols : 3
A PlaceHolder :
A "Enter your email address"
A ')
The RPG that populates EMAILADR on the form from the local DB.
LRNG_SetNumProperty('/Form.Vars.SFID' : SavedState.MC3SFID );
LRNG_SetProperty( '/Form.&.TBL' : 'CEMobileUserData');
LRNG_SetProperty( '/Form.&.SQL'
: 'SELECT ROWID, CEMSFID, CEMUSERID, CEMLANGID'
+ ' FROM CEMobileUserData'
+ ' WHERE CEMSFID = &(VAR:SFID)' );
LRNG_Using('/Form.Fields');
LRNG_SetProperty('EMAILADR.Value.&.FLD' : 'CEMUSERID');
LRNG_EndUsing();
The problem I’m having is that when the user touches the Log On button or Return to process the log on attempt using the email address, the RPG attempts to retrieve the value of the screen element, but it’s always blank. I saw another issue where Tony suggested not using the bound element but rather get the value directly from the DB. How do I do that when the local DB field is bound to my screen element? At some point I need to get the email address into an RPG field that I can use to Chain to the user file on the IBM I. This is where I can't seem to work out the mechanism.
wrkEmailAdr = LRNG_GetPropAsStr('Form.Fields.EMAILADR.Value'); // this works if unbound. When bound it returns blank.
If I leave EMAILADR as an unbound element, I can retrieve its value, but then of course the initial value isn’t set from my local SQLite DB on the device (a feature the sales reps here have requested). How do I get the value from the bound element into an RPG field ?
So in summary, I'm trying to save some log on information locally on the device so the user doesn't always have remember and key in the log on values. Ultimately I need to use that value to process my log on as though the user had keyed the value in. I just can't work out how to get the value of my bound data into an RPG field (50A).
I’ve gone through the Foundation and Advanced Offline documents and created my own variations of the shipped examples but I would still consider myself an offline noob. Any help would be appreciated.
Online Form with a bit of local data
-
MarkDuignan
- Posts: 346
- Joined: Wed Apr 18, 2012 10:33 am
Re: Online Form with a bit of local data
Try making an ECL script that runs when the form loads.
That would the SQL command and not be bound to anything.
It should then be able to set the result value it finds into the email field as a prefill. The email field would be normal and unbound.
That would the SQL command and not be bound to anything.
It should then be able to set the result value it finds into the email field as a prefill. The email field would be normal and unbound.
-
MarkDuignan
- Posts: 346
- Joined: Wed Apr 18, 2012 10:33 am
Re: Online Form with a bit of local data
Is the CEMobileData table a generic place to remember many different things (ie: not just user email addresses)? If it is you might be able to create a generic ECL that does this for any nominated screen element(s)?
The shipped example EXAM0120 (in schema longrangeofflinedemo -> Example Programs -> Advanced Example Programs -< EXAM0120) shows an example of calculator. This shows reading from and writing back to screen fields. Note that EXAM0120 has both the RPG code and client side ECL script all in one program.
EXAM0122 shows SQL commands being executed in ECL scripts that output their results to the screen. It used procedure EZI_LoadECLfromMember procedure to read the ECL script from source members EXAM0122A and EXAM0122B. This is really no different to EXAM0120 using a compile time array - but it’s more flexible than putting them into compile time arrays because you can just edit the ECL, save and run the test again instantly – no recompiles required.
This should supply most of the pieces you need. Remember to use developer’s console and output messages to it from your ECL scripting – this is the easiest way to debug. Attaching client side ECL scripting is a bit hard at first – but it is very flexible, generic and powerful.
Any problems just yell.
The shipped example EXAM0120 (in schema longrangeofflinedemo -> Example Programs -> Advanced Example Programs -< EXAM0120) shows an example of calculator. This shows reading from and writing back to screen fields. Note that EXAM0120 has both the RPG code and client side ECL script all in one program.
EXAM0122 shows SQL commands being executed in ECL scripts that output their results to the screen. It used procedure EZI_LoadECLfromMember procedure to read the ECL script from source members EXAM0122A and EXAM0122B. This is really no different to EXAM0120 using a compile time array - but it’s more flexible than putting them into compile time arrays because you can just edit the ECL, save and run the test again instantly – no recompiles required.
This should supply most of the pieces you need. Remember to use developer’s console and output messages to it from your ECL scripting – this is the easiest way to debug. Attaching client side ECL scripting is a bit hard at first – but it is very flexible, generic and powerful.
Any problems just yell.
-
JimKeating
- Posts: 12
- Joined: Thu Apr 19, 2012 11:45 pm
Re: Online Form with a bit of local data
Mark, Thanks for the feedback. I will give ECL a try. Since this was our first attempt at doing anything with a local DB in CE Mobile, we thought we'd start with something simple so for the moment saving the email is the only usage but I understand your point on a generic routine for future additions.