NetTalk Central

Author Topic: Calling Form for Single Record File  (Read 5741 times)

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Calling Form for Single Record File
« on: October 14, 2012, 01:39:59 AM »
I have a NetWebPage with an image "button" that is calling a Form.  The file for the form is a single  record file, so I am calling it without a browse to select from.

I have read FAQ4 and looked at example 24, and in my calling program (the netwebpage), I have the following html for the image:

<a href="MoneyCounterMenu?change_btn=change&_bidv_=' & p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)">

MoneyCounterMenu is the netwebform procedure that is being called.  RecordContributionsMenu is the calling netwebpage.  ContWS is the single record file.  CWS:KeySysID is the key, and the value of the SysID field for the single record is 1.

When I run the app, the form is called and the following is in the browser address bar:

http://127.0.0.1/MoneyCounterMenu?change_btn=change&_bidv_=' & p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)

But, I get an error message:

record not found: (-2) Error 30: Entry Not Found from key CWS:KeySysID

I have verified that there is only one record in the ContWS file and
Suggestions?
Mike Springer

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Calling Form for Single Record File
« Reply #1 on: October 14, 2012, 03:48:19 AM »
Hi Mike,

& p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1) &


That piece of code needs to be executed by clarion. So your URL should look like

<a href="MoneyCounterMenu?change_btn=change&_bidv_=AJ5g7m8r">


Where the "AJ5g7m8r" will change but look similar its the token to indicate what record to edit (thats why your getting error 2 record note found.

So something is wrong based on how you are generating the link.

Regards
Bill

rjmiller

  • Jr. Member
  • **
  • Posts: 91
    • View Profile
    • Email
Re: Calling Form for Single Record File
« Reply #2 on: October 14, 2012, 07:19:01 AM »
Mike,

I do something similar in several of my apps.  I had a lot of problems too but there is a thread in this forum that helped me...  basically use a memory form and do the saving as per the advice from charl99 as in the thread below:

http://www.nettalkcentral.com/index.php?option=com_smf&Itemid=36&topic=3704.0

Hope this helps you too.

  RJ
« Last Edit: October 14, 2012, 07:24:00 AM by rjmiller »

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Calling Form for Single Record File
« Reply #3 on: October 14, 2012, 11:15:30 AM »
Bill,
I don't know how the record "token" gets generated.  I do know the unchanging key value of the single record.  You can see that in my code there (a value of 1).  So, how does that "hash" token get created if I know the actual value of the record?
Mike

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Calling Form for Single Record File
« Reply #4 on: October 14, 2012, 07:15:59 PM »
Hi Mike,

p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)

is a function that generates a short string (its a token that allows NT to find your Unique key, but its done so you dont "advertise" your unique IDs in the URL or POST data, because that makes it very easy for an evil person to hack your site and do nasty stuff.

When that token is passed in a URL using this variable "_bidv_" NT can then decode it and locate your unique ID and get the correct record.

If you get Error -2 its not working. In your example HTML the function "p_web.AddBrowseValue('" etc was actually showing up in the HTML and that just means youve made a mistake where ever you used it. Some how you got the literal value in the HTML whereas you want the function result.

Regards
Bill

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Calling Form for Single Record File
« Reply #5 on: October 14, 2012, 09:33:48 PM »
 Hi Mike,

>>I have the following html for the image:

>> <a href="MoneyCounterMenu?change_btn=change&_bidv_=' & p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)">

Perhaps post the actual, whole line of code here. Presumably it starts with packet = , and there are more quotes and so on. You've got the quotes in the wrong places it seems to me, but I can only be sure if you post the exact line as it appears in your code.

cheers
Bruce


springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Calling Form for Single Record File
« Reply #6 on: October 15, 2012, 02:34:32 AM »
The procedure that is calling the form for a single record file is a netwebpage with and image that calls the form.  Here is the HTML on the calling netwebpage:

<div id="wb_Image1" style="position:absolute;left:30px;top:180px;width:32px;height:32px;z-index:12;" align="left">
<a href="MoneyCounterMenu?change_btn=change&_bidv_=' & p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)"><img src="images/Contribution2.jpg" id="Image1" alt="" align="top" border="0" style="width:32px;height:32px;"></a></div>

Bill is correct, the sysid value of "1" is showing up in the url, and I am getting the -2 error.

Mike

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Calling Form for Single Record File
« Reply #7 on: October 15, 2012, 04:59:54 AM »
Hi Mike,

I'm guessing that the HTML is being added in the xHTML tab? (and as such the clarion function isnt running but rather its literal value is being sent to the browser).

If so, you need to find a corresponding embed point and place, this into it:

packet = clip(packet) & '<div id="wb_Image1" style="position:absolute;left:30px;top:180px;width:32px;height:32px;z-index:12;" align="left">
<a href="MoneyCounterMenu?change_btn=change&_bidv_=' & p_web.AddBrowseValue('RecordContributionsMenu','ContWS',CWS:KeySysID,1)&'"><img src="images/Contribution2.jpg" id="Image1" alt="" align="top" border="0" style="width:32px;height:32px;"></a></div>'

Copy it exactly - as I've added a few ' in strategic places.

Regards
Bill

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Calling Form for Single Record File
« Reply #8 on: October 15, 2012, 05:39:40 AM »
Hi Bill,
Your assumption is correct - the HTML was added in the xHTML Tab.

I took your suggestion and added your code it to the Processed Code embed on the NetWebPage just before the "do Footer" call.  I added the Do SendPacket right after your code.  And, as you predicted - it worked perfectly.

Bruce, so should an "AddBrowseValue" appearing in the xHTML Tab be able to call the code to convert the literal key value to the encoded value be added in the NT template - or would you recommend that this kind of xHTML be done in an embed in the future?

Thanks guys, for your always insightful instruction.
Mike

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Calling Form for Single Record File
« Reply #9 on: October 15, 2012, 09:20:28 PM »
>> Bruce, so should an "AddBrowseValue" appearing in the xHTML Tab be able to call the code to convert the literal key value to the encoded value be added in the NT template -

no.
The xHtml tab is for "static" html only. There's no programming code in there. (Because it uses QUOTE to convert < to << and ' to '' so there's no way to put code in there.)

>> or would you recommend that this kind of xHTML be done in an embed in the future?

yes, exactly what I would have suggested.

cheers
Bruce