Import + Global variables + linked fields

Import + Global variables + linked fields

Hi everyone, and thanks fro stopping by…

 

Here is a problem I have, I already spent several hours on it without success, so you're my last hope... (codes are below).

 

I have 2 forms in 2 applications: Form1 in App1 and Form2 in App2. Form1 is for contacts and form2 is for restaurants.

 

For each contact I have to link a restaurant, I can link the same restaurant to several contacts (the manager, the chef, the waiter...)

 

Each restaurant has a reference contact, who is in the contact list.

 

In the App1.form1, there is only the name of the restaurant, and all the other information about the restaurant (address, phone...) are in the App2.Form2.

 

When I import data from CSV, I affect the columns to Form1 for contact info, and to form2 (via related_fields) for restaurant info.It creates contacts in app1 and restaurants in app2.

 

I need some info to be in both app, such as the state and the country. So on validate in the form1 I copy the data from form2 to form1. This works very well.

 

I would need to do the same thing from app1 to app2... I want the name of the contact from who was created the restaurant to be the reference contact. But impossible to do that !!

 

I tried with global variables, extracting the data from form1 via a function1, and using it via another function2.

 

Both functions are in app1.

In Form1 on validate I call function1, which updates the global variables I need. (First and Last Name, and Email). I tested the function, it works.

 

In form2 on success I get the global variables values, then I call function2 (the arguments of function2 are the variables updated with function1).

That function2 updates a global variable contactref = FirstName + LastName + Email, and returns its value. Function2 works too.

 

I want to insert the return of function2 in the Form2 in the field Ref_Contact.

 

Maybe there is something wrong with my codes… I’m working on that issue for days, and it drives me crazy!

 

Thanks for any help or suggestion.
 
Laure

 

Codes:

 

Function1:

  1. void data.datacontact(string LN, string FN, string EM)
  2. {
  3.     globalvariable.sample.updateglobalvalue("LastName", input.LN);
  4.     globalvariable.sample.updateglobalvalue("FirstName", input.FN);
  5.     globalvariable.sample.updateglobalvalue("Email", input.EM);
  6. }

 

Function2:

  1. string essai.manager(string LN, string FN, string EM)
  2. {
  3.     if (((input.LN  !=  null)  &&  (input.FN  !=  null))  &&  (input.EM  !=  null))
  4.     {
  5.         globalvariable.sample.updateglobalvalue("contactref", input.FN + " " + input.LN + " " + input.EM);
  6.         man = globalvariable.sample.getGlobalValue("contactref");
  7.     }
  8.     else
  9.     {
  10.         man = "";
  11.     }
  12.     return man;
  13. }

 

 

Form1 on validate, in application 1 (Contacts)

  1. thisapp.data.datacontact(input.Last_Name, input.First_Name, input.Email_Address);

 

 

Form2 on success

  1. if (input.Ref_Contact  =  null)
  2. {
  3.     LN = globalvariable.sample.getGlobalValue("LastName");
  4.     FN = globalvariable.sample.getGlobalValue("FirstName");
  5.     EM = globalvariable.sample.getGlobalValue("Email");
  6.     input.Ref_Contact = contacts.essai.manager(LN, FN, EM);
  7. }