PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 23 → Pull Record From Table Control, Send To Another Window
Pull Record From Table Control, Send To Another Window
Débuté par Ton, 30 mai 2018 13:01 - 2 réponses
Posté le 30 mai 2018 - 13:01
Hi,

My apologies for having posted this twice. There was an issue with the last thread, and I guess the only way to correct it was to delete the whole thread.

So I'm down to 2 days left in order to make the case for WINDEV Mobile and recommend to IT that we purchase with the 40% discount. I will try to be as clear as possible.

I am new to WINDEV Mobile. Zero experience. I have a very simple prototype that only needs to have 4 to 5 windows completed for me to show IT. I am using Express.

Basically I'm using an undocumented API (no API Spec File), hand written by the IT department. But it works just fine in my tests using Swagger Inspector. I'm using the following on a login window to access the API, authenticate, and get the token:

NOTE: The link to the API below is not real. Didn't think that was a good idea for a public forum. But the methods are real.

// API call - Method= ms1 & email
req is restRequest
req..URL = "https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=ms1&email=[%EDT_Email%]"
resp is restResponse = RESTSend(req)
Jrec is Variant = JSONToVariant(resp.Content)
IF Jrec[1] = 0 THEN
sEmailaddrEXPRESSEXPRESSEXPRESS is string = Jrec[2]
ELSE
ToastDisplay("invalid email")
RETURN
END

// API call - Method= ms2 & email & password
req..URL = "https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=ms2&email=[%EDT_Email%]&password=[%EDT_Password%]"
resp = RESTSend(req)
Jrec = JSONToVariant(resp.Content)
IF Jrec[1] = -1 THEN
ToastDisplay("invalid Password")
RETURN
END
gsToken = Jrec[2]


I can then use that token to populate a table control on the next window using the following local procedure:

req is restRequest
req..URL = "https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=card-list&token=[%gsToken%]"
resp is restResponse = RESTSend(req)
Jrec is Variant = JSONToVariant(resp.Content) // this is an array of json records.

// Now loop thru the json records in the variant and add them to the array or at least to the table (don't have to do both)
// the for each LREC declares LREC as the record structure for each of the jrec variant

FOR EACH lrec OF Jrec

TableAddLine(TABLE_List1,lrec.card_last_4,lrec.cardholder,lrec.period_avail,lrec.card_status)

END
gsCard_secure_ssl = Jrec[2]


All of this seems to work fine. The trouble I'm having is that the data returned is a list of users (cardholders). I need to be able to select a user, and then populate the next window with that user's specific data. (send their records to a new window)

The data for this next window (which is a Looper Control) needs to be in a single column (maybe 2 columns for the 1st row) with 6 to 8 rows of selectable data, which will then need to go to a new window once selected.

Here is the Looper Window local procedure:

Procedure Init()

req is restRequest
req..URL = "https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=stats&token=[%gsToken%]&card=[%gsCard_secure_ssl%]"
resp is restResponse = RESTSend(req)
Jrec is Variant = JSONToVariant(resp.Content) // this is an array of json records.

// Now loop thru the json records in the variant and add them to the array or at least to the table (don't have to do both)
// the for each LREC declares LREC as the record structure for each of the jrec variant

FOR EACH lrec OF Jrec

LooperAddLine(LOOP_Content,lrec.card_last_4,lrec.cardholder,lrec.decline,lrec.pending,lrec.posted)

END


There is a second token "gsCard_secure_ssl" needed to pull in specific cardholder data. I may not have coded this correctly, because the Looper window is blank. If I use a Multiline Zone instead of a Looper, I at least get values of "0" returned. Not sure what that means.

If someone could help me with this issue, I might be able to use that for all subsequent record pulls. I'm so close!!!

Thanks so much!!!
Posté le 30 mai 2018 - 14:28
what are
lrec.card_last_4,lrec.cardholder,lrec.decline,lrec.pending,lrec.posted ?

Are they FIELDS or are they ATTRIBUTES of the looper ?

IF they are fields, create the apporpiate attributes and use them instead

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on http://www.fabriceharari.com


On 5/30/2018 5:01 AM, Ton wrote:
Hi,

My apologies for having posted this twice. There was an issue with the
last thread, and I guess the only way to correct it was to delete the
whole thread.

So I'm down to 2 days left in order to make the case for WINDEV Mobile
and recommend to IT that we purchase with the 40% discount. I will try
to be as clear as possible.

I am new to WINDEV Mobile. Zero experience. I have a very simple
prototype that only needs to have 4 to 5 windows completed for me to
show IT. I am using Express.

Basically I'm using an undocumented API (no API Spec File), hand written
by the IT department. But it works just fine in my tests using Swagger
Inspector. I'm using the following on a login window to access the API,
authenticate, and get the token:

NOTE: The link to the API below is not real. Didn't think that was a
good idea for a public forum. But the methods are real.

// API call - Method= ms1 & email
req is restRequest req..URL =
"https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=ms1&email=[%EDT_Email%]"
resp is restResponse = RESTSend(req) Jrec is Variant =
JSONToVariant(resp.Content) IF Jrec[1] = 0 THEN
    sEmailaddrEXPRESSEXPRESSEXPRESS is string = Jrec[2] ELSE
 ToastDisplay("invalid email")
 RETURN
END

// API call - Method= ms2 & email & password
req..URL =
"https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=ms2&email=[%EDT_Email%]&password=[%EDT_Password%]"
resp = RESTSend(req) Jrec = JSONToVariant(resp.Content) IF Jrec[1] = -1
THEN
    ToastDisplay("invalid Password")
    RETURN
END
gsToken = Jrec[2]


I can then use that token to populate a table control on the next window
using the following local procedure:

req is restRequest
req..URL =
"https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=card-list&token=[%gsToken%]"

resp is restResponse = RESTSend(req) Jrec is Variant =
JSONToVariant(resp.Content)   // this is an array of json records.

// Now loop thru the json records in the variant and add them to the
array or at least to the table (don't have to do both)
// the for each LREC declares LREC as the record structure for each of
the jrec variant

FOR EACH lrec OF Jrec
    TableAddLine(TABLE_List1,lrec.card_last_4,lrec.cardholder,lrec.period_avail,lrec.card_status)

END
gsCard_secure_ssl = Jrec[2]


All of this seems to work fine. The trouble I'm having is that the data
returned is a list of users (cardholders). I need to be able to select a
user, and then populate the next window with that user's specific data.
(send their records to a new window)

The data for this next window (which is a Looper Control) needs to be in
a single column (maybe 2 columns for the 1st row) with 6 to 8 rows of
selectable data, which will then need to go to a new window once selected.

Here is the Looper Window local procedure:

PROCEDURE Init()

req is restRequest
req..URL =
"https://example.dev.com/mobile-app/folder/web-service/mobile-api.php?method=stats&token=[%gsToken%]&card=[%gsCard_secure_ssl%]"

resp is restResponse = RESTSend(req) Jrec is Variant =
JSONToVariant(resp.Content)   // this is an array of json records.

// Now loop thru the json records in the variant and add them to the
array or at least to the table (don't have to do both)
// the for each LREC declares LREC as the record structure for each of
the jrec variant

FOR EACH lrec OF Jrec
    LooperAddLine(LOOP_Content,lrec.card_last_4,lrec.cardholder,lrec.decline,lrec.pending,lrec.posted)

END


There is a second token "gsCard_secure_ssl" needed to pull in specific
cardholder data. I may not have coded this correctly, because the Looper
window is blank. If I use a Multiline Zone instead of a Looper, I at
least get values of "0" returned. Not sure what that means.

If someone could help me with this issue, I might be able to use that
for all subsequent record pulls. I'm so close!!!

Thanks so much!!!
Posté le 30 mai 2018 - 15:18
Hi,

The "stats" method of the API call:
Called from clicking on a card in the previous card-list window with POST["card_secure_ssl"].
Used to show the number of transactions for each transaction status.
Returns an object with at least 3 properties:
- pending - number of pending transactions for card
- posted - number of posted transactions for card
- declined - number of declined transactions for card

I added the others (card_last_4 and cardholder) as a test. I had previously obtained data from them in the previous window, and I just wanted to see if I could do the same here. Didn't work.

Does that help to answer your question?

---

Fabrice Harari wrote:
what are
lrec.card_last_4,lrec.cardholder,lrec.decline,lrec.pending,lrec.posted ?

Are they cardholder ?

IF they are fields, create the apporpiate attributes and use them instead

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Free Video Courses, free WXShowroom.com, open source WXReplication, open
source WXEDM.

More information on http://www.fabriceharari.com