Announcement

Collapse
No announcement yet.

Multi-Enum, Phone, and Email Autopopulation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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);
    ?>

  • #2
    Help Please!

    Comment


    • #3
      Multienum are stored like

      Value1:,:Value2:,:Value3

      Comment


      • #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


        • #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.

          Comment


          • #6
            okay, will do!

            Comment


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

              Comment

              Working...
              X