New Field of type "Select" doesn't update existing Select-Field

Hi there

I do have the following problem: In a form I added a New Field of Data Type Select. And now I want to use AJAX Event on Change to reload an existing Select Field, but it doesn’t work.

I did this on several other forms before with existing Select-Fields, and it works perfect, but with an added “New Field” it doesn’t. Any adea why??

Thanks very much for your help.

hello, can you give more information like what you are trying to fetch and what is settings/code used to reload the existing field…etc.

Hello MikeDE

  • I have one table ([B]course_contac[/B]t) where I can asign a contact (contact_ID) to a course (course_ID). Table structure is as follows: ID, contact_ID, course_ID, other fields....
  • I have an other table ([B]course[/B]) where I can hold all my courses. Every course has an ID (course_ID) and belongs to a group (group_ID). Table structure is as follows: course_ID, group_ID, other fields ....
  • I have a table for all my course-groups ([B]groups[/B]). Table structure is as follows: group_ID, other fields......

And now I want to add or edit entries in table course_contact. I want to filter my courses by group, and because I do not have the field group_ID in my table course_contact I added a New Field with Data Type “Select” to my form and checked "Use AJAX to reload … course_ID ".

I do all my settings in the form the same way as I would with an existing Field, but it doesn’t work with a New Field. Why??

I hope my explanation is understandable for you and I hope you can help me, because I use this things quite often in my programmings.

Thank you very much in advance

ss_02.png

ss_01.png

I’ve seen these type of issues intermittently with SC. I don’t see anything wrong with your code as is the case with mine too. I typically do this:

​- set to off in Ajax processing of GruppeID; regenerate

  • set to on again and regenerate; retry to see if it works if not…
  • in some cases I’ve had to create ajax event onChange on GruppeID and in it sc_setfocus to KursID, perform the SELECT SQL (using sc_lookup) in your KursID and then set KursID = {rs[0][0]}
  • sometimes I’ve just re-created the form from scratch and it worked

scriptcaser is current, sometimes scriptcase behave stragne, try new form from scratch… or try to adjust in the sql statement itself, sometimes (for unknown reason) if you change the order by xxxx to id, it works, or add select ID, xxxx then it works, eventhough it displayes the xxxx ,not the ID itself

@ scriptcaser: I tried your suggestions No 1, No 2 and No 4, but non of them worked. No 3 I couldn’t test right now, because I don’t know how to do it. I’m pretty new to scriptcase and I need to learn quite a lot. I’ll let you know as soon as I find out how to do it.

@ MikeDE: I tried to change the SQL-Statement as you suggested, but without success. It seems so that scriptcase doesn’t use the variable from GruppeID in WHERE Clause. If I use a fixed Value everything works fine.

To both of you: I’m happy that it’s not me who doesn’t understand how it should work. Hopefully we will find an work around, because I start to like scriptcase and I want to stick with it.

Thanks once againfor your help.

dude, did you start a new one from scrach and go step by step, see where it starts gets crazy and changes the statement!?

Hold on a sec @HoWin: in your primary select, the Field list has GruppeID but in the SQL Select Statement associated, you are pulling KategorieID and Kategorie. Logically I would expect this to work (i.e. assign KategorieID to {GruppID}) but who knows how SC is coded internally? Since you say it fails because of content of {GruppeID}, I would first try unifying the names i.e. pull KategorieID into {KategorieID}.

My suggestion 3 I just realized works for a different use case: where I need just a single value from the dependent SELECT statement (you need 2: the ID field and the display value). To get it to work for yours needs a lot more hacks and it seems overkill: there’s got to be a simpler way. Try above first.

He scriptcaser

Thanks for your input and I will try this 3 weeks, because I am on holidays from today on until first week in september.

In the meantime I made a work-around: I added the field GroupID to my table too. It would not be neccessary, but in that case Scriptcase works and it doesn’t hurt me. But I wondered why it won’t work with a New Field.

So, I try your suggesions in about 3 weeks. Thanks very much for your help. I’ll keep you informed.

Best regards

HoWin

Glad it worked.

Typo in what I wrote: instead of “…i.e. pull KategorieID into {KategorieID}” I meant to write “…i.e. pull GruppeID into {GruppeID}”. This unifies the names and you’ve achieved it by pulling GruppeID from the db. Nothing more to try…enjoy the vacation. :slight_smile:

Rgds

Hello scriptcaser

Now I’m back from holidays and I tried out your suggestions, but I’m sorry, either I do something wrong or it still doesn’t work.

So, I created a new mask from scratch and used the same names than in the database.

Here are some some screenshots with explanations from what I’ve done:

  • SC_SS_01.png: shows the settings for KategorieID
  • SC_SS_02.png: shows your suggestions. I hope I didn't missunderstand you.
  • SC_SS_03a, -b, -c.png: shows the results :-(
  • SC_SS_12.png: here I set up the SQL-Statement withount curley brackets
  • SC_SS_13a, -b, -c, -d.png: Now I do not get any Error-Message, but the WHERE Clause dosn't work at all. I allways see all entries from KursID
  • SC_SS_DB_01.png: Database-table "kur_kurse_kategorien"
  • SC_SS_DB_02.png: Database-table "kur_kurse"

If it works with your settings, what do I wrong that it doesn’t work with my settings? Any idea?

Best regards,

HoWin

SC_SS_03b.png

SC_SS_03a.png

SC_SS_03c.png

SC_SS_01.png

SC_SS_02.png

… here are attachements part 2

SC_SS_13d.png

SC_SS_13c.png

SC_SS_13b.png

SC_SS_12.png

SC_SS_13a.png

… and here are the attachements part 3

SC_SS_DB_01.png

SC_SS_DB_02.png

Hello scriptcaser

On September, 09 th i answered to your suggestions, but unfortunatelly I wrote the answer to Senior Member istead of your name. Thant’s why my question to you: Could you please have an other look to my problem? See my entry from Sept. 09. It still doesn’t work as it should. Maybe you know what’s wrong.

Thank you very much in advance for your help.

Regards,

HoWin

hello Howin,

can we setup small teamviewer session, i want to try couple of quick things directly on your dev, seems not english and looks similar words confuse me a bit… or maybe scriptcaser can help or/and knows your language :slight_smile:

by the way, Senior Member is not a name, that is title by vb forum based on the count of the posts/replies i guess

cheers

Hello MikeDE

Yes please, let us make a teamviewer session. How should we do this. I live in Austria, and it seems so that you are from Germany :slight_smile:

How can we get in contact??

see you…

Hi everyone,

I’ve been playing with SC8 during the trial period and I enjoy it very much. While building a quite large form with a “select” field with the EDIT button I came across the same problem: the select field of the form is not updated after coming back from the update popup window. I tried the feature in a short test project and it worked seamlessly. So, I think, as you discussed earlier, that is something with the inner coding of SC8.
Anyway, I worked around it, and that solved my problems. Maybe that’s gonna be useful for somebody who is hanging on this.

  1. Let’s use the names:
    The parent form: “form_a”
    The select field on form_a: “select_a”
    The update popup form - that updates “select_a”: “form_b”

  2. Create a session variable. (Let’s say that is [s_app_flag])

  3. In “form_a” at onLoad event give any value to s_app_flag. (e.g. [s_app_flag] = ‘called’) That will indicate our project that we are inside “form_a”.

  4. In “form_b” at onValidateSuccess event check if the form was called from “form_a” and if yes, reload “form_a”:

            if ([s_app_flag] === 'called')
               {
               sc_ajax_javascript('window.opener.location.reload()');
               };
    

The above javascript code will reload the calling form and the “select_a” select field will be updated with the new data set.
4. Exit the popup “form_b” window and continue working on “form_a”
5 The last step is to delete [s_app_flag] when you exit from “form_a”. That is important for preventing “form_b” from reloading any other calling form.
In “form_a” at onValidateSuccess event:

           [s_app] = '';

It looks like a rather complicated process, but actually it can be done in no time.

Best rgrds:
​Gyorgy

interesting approach, thank you for the info…
just i think no need for that complex… did you have a look at their video tutorial for this function it is explained easy to the point… and was tested before…
i guess Howwin is missing small thing only

Him MikeDE,

Yes, I did, actually I enjoy those video courses. I tried everything but I couldn’t get it moving.
Actually, the official way is really very simple that’s why I think I’ve done (and re-done a couple of times) all steps by the papers but with negative results.
I don’t want to remake the form from scratch because it’s rather complicated, and applying the method above solved my problem. :slight_smile: