GravityWiz UniqueID Round Robin to Zapier

I’m trying to figure out how to hook into grabbing the unique ID after it’s generated so that I can use it to send a proper Sales Rep ID and Name to Zapier and then to PipeDrive. I’m currently using the sequential option starting at 1 and then using modulus to determine the order.

Here’s my current code:

$uniqueID       = rgpost('input_27');
if($uniqueID) {
        $i = $uniqueID%3;
        if($i == 0) {
            $salesRepName   = 'SR_1';
            $salesRepID     = '01010101';
        } elseif( $i == 1) {
            $salesRepName   = 'SR_2';
            $salesRepID     = '01010102';
        } else {
            $salesRepName   = 'SR_3';
            $salesRepID     = '01010103';
        }

        $_POST['input_28'] = $salesRepName;
        $_POST['input_29'] = $salesRepID;
    }

My assumption is that Unique ID is generated after the submission and this may be an issue since I’m hooking into gform_pre_submission.

Is there a better method to ensuring this gets stored to the entry and also hits the zapier push? I’m sure it’s just a matter of changing my hook.

I’m banging my head against the wall at the moment. @david you think you could help me out here?

I saw that you’re doing this:

// Priority 8 so ID is generated before GF Feeds are processed (10) and gives other plugins a chance to do something with the generated ID before the GF Feeds are processed as well (9).
add_filter( 'gform_entry_post_save',    array( $this, 'populate_field_value' ), 8, 2 ); 

So I changed my hook to run after yours and it’s still not working. I ran a print_r on the front end and entry 27 is properly set as the unique ID.

Here’s the current code.

add_filter( 'gform_entry_post_save', 'cta_round_robin_post_save', 10, 2 );
function cta_round_robin_post_save($entry, $form) {
        if($form['id'] == 18) {

            $userProduct  = rgar($entry, '9');
            $uniqueID = rgar($entry, '27');
            $salesRepName = '';
            $salesRepID = '';


            if($uniqueID) {
                $i = $uniqueID%3;
                if($i == 0) {
                    $salesRepName   = 'SR_1';
                    $salesRepID     = '11345031';
                } elseif( $i == 1) {
                    $salesRepName   = 'SR_2';
                    $salesRepID     = '11345001';
                } else {
                    $salesRepName   = 'SR_3';
                    $salesRepID     = '11345029';
                }
            }

            if($userProduct == 'Pool Enclosures') {
                $salesRepName   = 'SR_2';
                $salesRepID     = '11345001';
            }

            $entry['28'] = $salesRepName;
            $entry['29'] = $salesRepID;

        }

        return $entry;
}

Thanks in advance.

Hi Nick. Are you using GP Unique ID for something else, making that required here, or is the result only that you want to use three different Sales Reps in your Round Robin for Pipedrive and Zapier (meaning you could do this without GP Unique ID)?

I’m using GP Unique ID to determine which rep it needs to go to. We have like 10 forms on this site and there is a caveat with one of the products (pool enclosures) that only one of the sales people actually takes those sales calls.

I figured the best approach would be to use GPUID in sequential and only let it iterate if the pool enclosures is not selected, which is all working as expected.

The issue seems to be that the values for the SalesRepID and SalesRepName are not saving to the Entry. However, I did just realize they’re properly being pushed to Zapier and subsequently PipeDrive.

I also added gform_post_add_entry to the chain and it’s still not saving to the entry. I don’t think it’s mandatory, but it would be nice incase I ever need to run an export on the form I’d have that information on hand.

I’m open to suggestions.

I should also add, that I’ll probably extend this to the notifications as well so that I can send the proper sales rep an email directly from GF. Although, this should be straight forward if I can save the proper entry details.

OK, so you are half way there? You just need to add that unique ID to the entry for future reference, correct?

The unique ID is being added properly.

The values I’m defining are not being added to the entry.

  • Sales Rep name => Entry 28
  • Sales Rep ID => Entry 29

gform_entry_post_save does not save the values to the entry. It only makes them available to notifications or confirmations. From the doc page:

This new value will be available for use in notifications and confirmations, but the updated text is NOT saved with the entry.

So you’ll need a different hook or filter. If you enable logging, can you see which hooks run before the GPUID code runs? The logs will be sequential, so you can see in which order they are run.

Also, David has this guide which may be helpful in selecting a new filter/hook:

1 Like

I just facepalmed myself.
:man_facepalming: :man_facepalming: :man_facepalming:

1 Like

I’ve been saying all day “I’m missing something so simple”

1 Like

Hey @nickhempsey, was traveling last week. Did @chrishajer get you sorted?