PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Get question from form for use in post_submission_handler

  1. sccr410
    Member

    I am trying to write a script that takes the form data and sends it to a 3rd party CRM. I have a "Notes" box where most of the data needs to go, but I need to somehow get what the question is to include in the Notes box.

    The $entry array only has field IDs, and for radio/checkboxes it does decimal numbers for each option. This means I can't even manually include in the script a direct relationship because I could have array indexes 17.3, 17.4, 17.9 - I don't know for sure which index IDs will even be available.

    How can I simply grab Question/Answer and send it to this CRM?

    Posted 13 years ago on Monday March 14, 2011 | Permalink
  2. I can send you a code snippet to point you in the right direction. Can you give me a little more information on how you would want the data formatted? I understand you want a Question - Answer format of some sort, but can you be a little more specific? Especially for the checkbox field, where there could be more than one answer for each question.

    Posted 13 years ago on Tuesday March 15, 2011 | Permalink
  3. sccr410
    Member

    In a general Notes field, I want to send data like:

    Question: Answer

    So, example:

    Method of Contact: Phone
    Business URL: http://www.domain.com
    Services: Web design, SEO, Logo Design

    Posted 13 years ago on Tuesday March 15, 2011 | Permalink
  4. Try the following:

    add_action("gform_post_submission", "send_to_third_party", 10, 2);
    function send_to_third_party($entry, $form){
        $notes = "";
        foreach($form["fields"] as $field){
            $value = RGFormsModel::get_lead_field_value($entry, $field);
            if(RGFormsModel::get_input_type($field) == "checkbox")
                $notes .= $field["label"] . ": " . implode(", ", array_values($value)) . "\n";
            else
                $notes .= $field["label"] . ": " . GFCommon::get_lead_field_display($field, $value) . "\n";
        }
    
        //Send $notes to third party
    }
    Posted 13 years ago on Wednesday March 16, 2011 | Permalink
  5. sccr410
    Member

    Perfect, thank you!

    Posted 13 years ago on Wednesday March 16, 2011 | Permalink