You are viewing limited content. For full access, please sign in.

Question

Question

How to check duplicates before insert

asked on April 4, 2018

Hi all,

 

Using a Web Form, I want to insert value in my database. But before to insert, I need to check if the value doesn't exist.

 

This is my database

 

To help me, I created the field RID. This is my field that I will check.

RID = fk_marque & modele

 

Next, this is my form

 

RID = ID_Marque (hidden) & Modèle. I used javascript to merge them.

 

Next, I'm trying to populate the field "Erreur" using Search rules.

If Form's RID = Database's rid, then Form's Erreur = Database's id_modele.

 

 

As you can see in my previous picture, the field Erreur is empty and IDK why.

Need some helps please.

Regards

0 0

Replies

replied on April 4, 2018

Hi Olivier

As you used Javascript to create the  RID field, forms doesn't know that the field has a value in it and therefore doesn't run the lookup. You can either add some additional js to trigger the lookup after you populate the field such as I provided in thei post, or instead uses a forms calculation to create the RID value as forms will recognize when the value has been updated in the field.

=CONCATENATE(ID_marque,modele)

https://answers.laserfiche.com/questions/137731/Lookup-Rule-not-working-with-Java-Script#137732

Hope this helps

0 0
replied on April 5, 2018

Hi Steve,

 

I didn't use Javascript to "create" the RID field. I'm using Javascript only to "populate" the RID field.

How can I run the lookup using javascript?

 

0 0
replied on April 6, 2018 Show version history

Hi Olivier, I meant that you had used Javascript to create (populate) the RID field Value.

If instead of the using JS to populate the RID field and instead you used the following calculation in the RID field (under the Advanced) tab, then you won't need any Javascript at all
=CONCATENATE(ID_marque,modele)

This formula will Populate the RID field and the lookup will kick off as expected.

Of course you need to check that the appropriate field variable names are used in the formula to match your forms variables)

0 0
replied on April 9, 2018

Hi Steve,

 

thank you for your return.

I tried your solution, however the field is not fill immediatly. I need to click outside the field to get the information.

 

(Field is focus)

 

(Field lose focus)

0 0
replied on April 9, 2018

Yes, this would be correct, until you complete the field (Modele), indicated by clicking away from the field, or Tabbing to another field, then the field value is not accepted for use by Forms calculations to my understanding. But once you move away from Modele field, it should complete the RID field and run the Query, does it not?

0 0
replied on April 9, 2018

Yes once I move away from Model field, it complete the RID field and run the Query.

Anyway, to move away from Model field, the user can click the button submit then, at this moment, the form is submitted but the RID doesn't have yet the information.

0 0
replied on April 9, 2018

Sometimes I will hide the submit button until a condition is met, something checked, etc. maybe something to think about.

1 0
replied on April 9, 2018

Yes, this is what I do for the moment

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.