Multi-Enum, Phone, and Email Autopopulation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MiJo16CDAT
    Junior Member
    • Jul 2015
    • 27

    Multi-Enum, Phone, and Email Autopopulation

    I'm trying to send form data into espo so every time the form is submitted it auto populates the crm. But I don't know how espo handles multi enums, do I need to insert the string value of each option that was selected on the form that corresponds to the string or int of the crm. Also I'm trying to input data for the phone and email of the lead but the method I'm using doesn't' work... any advice?

    <?php

    //Get Connection
    require_once('connect.php');

    //Get Data
    $sql = "SELECT content FROM gwinnett_demo.wp_formcraft_3_submissions";
    $result = mysqli_query($con, $sql);

    if (mysqli_num_rows($result) > 0) {
    //Output data of each row
    while($row = mysqli_fetch_assoc($result)) {
    $row1 = $row["content"];

    //Decide data
    $json = urldecode(stripslashes($row1));
    $array = json_decode($json, true);
    print_r($array);
    if ($array[0]['label'] == 'First Name') {
    $partner_firstname = $array[0]['value'];
    }
    if ($array[1]['label'] == 'Last Name') {
    $partner_lastname = $array[1]['value'];
    }
    if ($array[2]['label'] == 'Phone Number') {
    $partner_phone = $array[2]['value'];
    }
    if ($array[3]['label'] == 'Email') {
    $partner_email = $array[3]['value'];
    }
    if ($array[4]['label'] == 'Your Organization Name') {
    $partner_companyname = $array[4]['value'];
    }
    if ($array[5]['label'] == 'Start of Availability') {
    $partner_starttime0 = $array[5]['value'];
    $myDateTimeStart = DateTime::createFromFormat('d/m/Y', $partner_starttime0);
    $partner_starttime = $myDateTimeStart->format('Y-m-d');
    }
    if ($array[6]['label'] == 'End of Availability') {
    $partner_endtime0 = $array[6]['value'];
    $myDateTimeEnd = DateTime::createFromFormat('d/m/Y', $partner_endtime0);
    $partner_endtime = $myDateTimeEnd->format('Y-m-d');
    }
    if ($array[24]['label'] == 'Comments') {
    $partner_description = $array[24]['value'];
    }
    if ($array[]['label'] == '') {
    $partner_firstname = $array[]['value'];
    }
    //Insert Data to another table
    $today = date("Y-m-d H:i:s");
    $assigned_user_id = "558045ce215226941";
    $sql = "INSERT INTO gwinnett_crm.lead (id, first_name, last_name, company_name, assigned_user_id, description, phone_var_char, target, created_at, modified_at) VALUES ('$partner_lastname$partner_companyname','$partner _firstname', '$partner_lastname', '$partner_companyname', '$assigned_user_id', '$partner_description', '$partner_phone', '$partner_involved', '$today', '$today');";
    $sql_e = "INSERT INTO gwinnett_crm.email_address (id, name, lower) VALUES ('$partner_lastname$partner_companyname','$partner _email', '$partner_email');";
    $sql_p = "INSERT INTO gwinnett_crm.phone_number (id, name) VALUES ('$partner_lastname$partner_companyname','$partner _phone');";
    $sql_e2 = "INSERT INTO gwinnett_crm.entity_email_address (entity_id, email_address_id, entity_type) VALUES ('$partner_lastname$partner_companyname','$partner _email', 'Lead');";
    $sql_p2 = "INSERT INTO gwinnett_crm.entity_phone_number (entity_id, entity_phone_number, entity_type) VALUES ('$partner_lastname$partner_companyname','$partner _email', 'Lead');";
    if (mysqli_multi_query($con, $sql)) {
    $traninfo = "New records created successfully"."<br>";
    } else {
    $traninfo = "Error: " . $sql . "<br>" . mysqli_error($con);
    }
    if (mysqli_multi_query($con, $sql_e)) {
    $traninfo = "New records created successfully"."<br>";
    } else {
    $traninfo = "Error: " . $sql_e . "<br>" . mysqli_error($con);
    }
    if (mysqli_multi_query($con, $sql_p)) {
    $traninfo = "New records created successfully"."<br>";
    } else {
    $traninfo = "Error: " . $sql_p . "<br>" . mysqli_error($con);
    }
    if (mysqli_multi_query($con, $sql_e2)) {
    $traninfo = "New records created successfully"."<br>";
    } else {
    $traninfo = "Error: " . $sql_e2 . "<br>" . mysqli_error($con);
    }
    if (mysqli_multi_query($con, $sql_p2)) {
    $traninfo = "New records created successfully"."<br>";
    } else {
    $traninfo = "Error: " . $sql_p2 . "<br>" . mysqli_error($con);
    }
    }
    } else {
    echo "0 results";
    }
    echo $partner_involved;
    $today = date("Y-m-d H:i:s");
    echo $today;
    mysqli_close($con);
    ?>
  • MiJo16CDAT
    Junior Member
    • Jul 2015
    • 27

    #2
    Help Please!

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      Multienum are stored like

      Value1:,:Value2:,:Value3
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • MiJo16CDAT
        Junior Member
        • Jul 2015
        • 27

        #4
        so if i multi enum had the following options

        Red
        Blue
        Green
        Purple
        Orange

        and I wanted to assign it red, blue, and purple but not green or orange I would pass the following string

        "Value1:"Red",:Value2:"Blue",:Value3:,:Value4:"Pur ple",Value5::"

        ​is that correct?

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #5
          I really don't remember. Can you find out and post the answer here? Save some record with multiEnum field and check what is stored in DB.

          I should be json array.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • MiJo16CDAT
            Junior Member
            • Jul 2015
            • 27

            #6
            okay, will do!

            Comment

            • MiJo16CDAT
              Junior Member
              • Jul 2015
              • 27

              #7
              ["value1","value2","value3","value4"]

              Comment

              Working...