NetTalk Central

Author Topic: NT Maps - update calling different table/record  (Read 4086 times)

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
NT Maps - update calling different table/record
« on: March 12, 2025, 12:50:11 AM »
Hi,

I fill the points table to be shown in a NT map dynamically.
When user clicks a pointer on the map, I need to update a record from a related table, and not the point record itself.

Is this possible?

tia
/Poul

Alberto

  • Hero Member
  • *****
  • Posts: 1882
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NT Maps - update calling different table/record
« Reply #1 on: March 12, 2025, 06:48:38 AM »
Hi, if I understand you... clicking on a pointer you can open a form, with this form you can do what you want.
-----------
Regards
Alberto

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #2 on: March 12, 2025, 07:46:16 AM »
Hi Alberto,

So in that form - a memory form I guess - would I be able to locate the record in the points table, use the ID for the related table, lookup that record and finally call the related tables updateform?

In the desktop version it is all very simple, since there is an embed "MapClicked Procedure", but no such embed in the NT version of the map.

So how would I achieve this?

tia
/Poul

Alberto

  • Hero Member
  • *****
  • Posts: 1882
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: NT Maps - update calling different table/record
« Reply #3 on: March 12, 2025, 10:07:21 AM »
See pic
-----------
Regards
Alberto

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #4 on: March 12, 2025, 01:06:19 PM »
Hi Alberto,

Thanks - I am aware of those settings, but I need to update the related record (job card) and not the record with the point.

Normally the code would be something like this:

Code: [Select]
!Load the map point record:
Access:MobHEREmap.ClearKey(Mmap:KeyGUID)
Mmap:GUID = p_web.GSV('Mmap:GUID')
IF Access:MobHEREmap.TryFetch(Mmap:KeyGUID)
   !failed
ELSE
    !Load the job-card record
    Access:MobSagH.ClearKey(MSagH:KeyGUID)
    MSagH:GUID =  Mmap:ID
    NOMEMO(MobSagH)
    IF Access:MobSagH.TryFetch(MSagH:KeyGUID)
        !failed
    ELSE
!Set the GUID for the update procedure:
        p_web.SSV('MSagH:GUID', MSagH:GUID)
    END   
END

I have made a Memory Form with above code in the Beginning of Procedure/ After opening files embed.
The UpdateMobsagH procedure is the only field on the Memory form.
The correct job record is located, but the form opens up empty.

I must be missing something.....
Or the approach using the Memory form like this is wrong ?
« Last Edit: March 13, 2025, 12:00:00 AM by Poul Jensen »

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #5 on: March 15, 2025, 11:14:15 AM »
Another attempt.
- Open the map points table update form when a point is clicked
- On that forms Set Form Settings embed lookup the job-card in question.  Also setting the GUID for the job-card:   p_web.SSV('MSagH:GUID', MSagH:GUID)
- Have the job-card update procedure as a field on this form.

The job-card update procedure opens with an error: Record not found.

I notice, that the Set Form Settings embed is NOT called on the job-card update procedure when called this way, but IS called when called normally from the job-card procedure.

Any suggestions?

/Poul

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #6 on: March 17, 2025, 12:11:39 AM »
Have now moved my code from embed SetFormSetting to AfterOpeningFiles, and now the code is called and the form seemingly opens with the correct record.

But I still get the Record Not Found error.

To track the executing order of the embeds in the job update procedure, I have placed debug strings.  I notice, that when called from the browse the embeds are called twice as many times compared to being called from the map.

See the attached images.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11296
    • View Profile
Re: NT Maps - update calling different table/record
« Reply #7 on: March 18, 2025, 02:29:16 AM »
I think you need to make an example showing what you are trying to do.
Debugging-from-descriptions is not enough for me.

Cheers
Bruce

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #8 on: March 18, 2025, 04:19:38 AM »
I will do that, but the approach of having a second update form on the update form for the point record, is that a good approach?

/Poul

Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #9 on: March 19, 2025, 10:12:41 AM »
Hi Bruce,

Revised web76 demo app that shows this behaviour emailed.

Cheers
/Poul

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11296
    • View Profile
Re: NT Maps - update calling different table/record
« Reply #10 on: March 23, 2025, 11:28:36 PM »
>> the approach of having a second update form on the update form for the point record, is that a good approach?

no.

A better approach, one that will work, is to call the form you want to call. In the example you sent me that would be UpdateUser, in your real app I expect it's UpdateJob, or whatever.

So now the issue is getting the correct record loaded in that table. I'll refer to the example you sent - the map is plotting the accidents, but you want to UpdateUser. So in UpdateUser, in the InitForm routine you need to prime the GUID value of the user to edit.

At this point all you have is the sesison value for the Accident. So the code goes something like this;

  Access:Accident.Open()
  Access:Accident.UseFile()
  Acc:Guid = p_web.GSV('Acc:Guid')
  Access:Accident.TryFetch(Acc:GuidKey)
  User:Guid = Acc:UserGUID
  Access:Accident.Close() 
  p_web.SetValue('Use:Guid',Use:Guid)
  p_web.SetSessionValue('Use:Guid',Use:Guid) 

This loads the Use:Guid into the Value, and SessionValue queues, and from there the form can take over.

Cheers
Bruce


Poul Jensen

  • Full Member
  • ***
  • Posts: 224
    • View Profile
    • Email
Re: NT Maps - update calling different table/record
« Reply #11 on: March 24, 2025, 12:00:46 AM »
Thanks Bruce,

Much simpler.....

And it works as suggested :-)

Any way I can detect in the final update form InitForm Routine how this is called.
It could be called from the browse or it could be called from the map, and the code in the InitForm would be different dependent on the calling procedure.

Just so I do not need to maintain two update forms.

Cheers
/Poul
« Last Edit: March 24, 2025, 11:30:53 AM by Poul Jensen »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11296
    • View Profile
Re: NT Maps - update calling different table/record
« Reply #12 on: March 24, 2025, 10:07:48 PM »
depends if the page is in popup mode or page mode.
You can't set a parameter easily from the Map side, since it's called directly from javascript, but you might be able to set a parameter on the browse side. And then check for that parameter (GetValue) in the form.