REPLACE FUNCTION

Hi,

In FMP we use Replace function to replace a field in the foundset with some value on it. Do we have a similar function in Servoy.

Currently I loop the whole foundset and update the value. But this is really slow when we deal with the heavy foundset.

In FMP the replace command is several times faster than looping through each record. Hope we will certainly have some faster method in Servoy.

Any suggestions?

Thanks
Ahmad

//update entire foundset
var fsUpdater = databaseManager.getFoundSetUpdater(foundset)
fsUpdater.setColumn('status','open')
fsUpdater.performUpdate()

this puts the status field on: open over the complete foundset!

Fast as light!

Hi HKJ,

Thanks for your reply. But I have a problem here

I have a main form which has relationless tabs for displaying contact list, product list etc.. (the whole database is driven from this main page only by showing or hiding the tabs)

My button which triggers the foundset update (which set tag = 1) is actually placed on the main form.

Now when I clicked this tag_all button it has to update my contact list foundset or anyother based on the current view.

var fsUpdater = databaseManager.getFoundSetUpdater(foundset)

When I use the above function the error says “foundset” is not defined.

Please tell me how to define a foundet which is actually displayed from relationless tab

Thanks
Ahmad

NO problem!

let’s say you have form: contacts_list in a tab-panel.

what I should do, is make a method on the form: contacts_list
updateRecords:

var tag = arguments[0] //takes over the tag variable from the calling method
var fsUpdater = databaseManager.getFoundSetUpdater(foundset) 
fsUpdater.setColumn('status',tag) 
fsUpdater.performUpdate()

than make a method on your main form which says:

var tag = 1
forms.contacts_list.updateRecords(tag)

Hope this helps

Hi,

Thanks..This will really help me..

Again.. I’m just trying to simplify and reduce scripts.

I have this tag_all option in all the different areas (contacts, products, quotes, events, news etc… etc… )

Based on your suggestion I have to create methods in all the above forms.

My idea is to common everything in one script called “globals.tag_all”

When I’m in the main form I know which form is showing on the tab

For eg: if the contact_list tab is showing then I have the name of the form called “frmContactList” in a global field

using the form name I will just concatenate as forms[globalFormName] and perform any actions like

forms[globalFormName].controller.search() or
forms[globalFormName].myField = “anything”

In all the tables the name of the tag field is “tag_general”

So I’m just thinking is there anything I can do like the following

foundset = forms[globalFormName].controller.foundset()
//I'm trying to link the current form for the following update action

var fsUpdater = databaseManager.getFoundSetUpdater(foundset) 
fsUpdater.setColumn('tag_general',"1") 
fsUpdater.performUpdate()

This will save lot of scripts for me. If this is not going to work then I will simply follow your method

Thanks
Ahmad[/quote]