The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Update a Form Field Entry when another Form is submitted

Labels

This Discussion is public

Notifications

Hi.   I have two forms.   Both Forms contain a Field (FIELD 1) which has a number in it and is used in both Forms.

When someone completes Form B, I want Form B's field 2 to populate across to Form A's field 4 if Field 1 in Form B equals Field 1 in Form A.

How can I do this with a snippet?

Help greatly appreciated.

 

Hi Craig,
There are two possible ways I can think of.

1. Use Formidable API plugin to update an entry in 2nd Form -https://formidableforms.com/knowledgebase/formidable-api/#kb-update-an-entry

2. Link both Forms using a Lookup field in the second Form so that you can auto-populate First form field values into second Form fields
https://formidableforms.com/knowledgebase/lookup/

Regards
Sujeevan

Thanks Sujeevan.

I was hoping to use code similar to this "Automatically update a field in another form"
add_action('frm_after_create_entry', 'link_fields', 30, 2);
add_action('frm_after_update_entry', 'link_fields', 10, 2);
function link_fields($entry_id, $form_id){
     if($form_id == 113){//Change 113 to the ID of the first form
         global $wpdb;
         $first_field = $_POST['item_meta'][25]; //change 25 to the ID of the field in your first form
         $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ". $wpdb->prefix ."frm_items WHERE id=%d", $entry_id));
$entry_ids = $wpdb->get_col("Select id from ". $wpdb->prefix ."frm_items where form_id='112' and user_id=". $user);//Change 112 to the ID of the second form
         foreach ($entry_ids as $e)
             $wpdb->update( $wpdb->prefix .'frm_item_metas', array('meta_value' => $first_field), array('item_id' => $e, 'field_id' => '6422'));//Change 6422 to the ID of the field to be updated automatically in your second form
  }
}
But that relies on a User ID to filter out which submission gets updated, and no one that completes a form with us has a user id, they are always logged out.

In my scenario both Forms will have a field which has the same value stored, so I want to update an entry where these fields have the same value stored.

Specifically:

An entry using form A would already exist.   In this entry there would, for example

Form A Field A - Value = U1000

Form A Field B - Value = (currently blank)

Someone would then use Form B make an entry.   In this entry there would be, for example

Form B Field A - Value = U1000

Form B Field B -  Value = Bob

So after this Form B entry is created or updated, I want Field B in Form A to now show Bob, as Both Form A Field A and Form B Field A have the same value.

 

 

HI, im looking for this solution also but with no luck

I feel rather than cross referencing the user, it needs to cross reference a matching field.. something like this...

 

$entry_ids = $wpdb->get_col("Select id from ". $wpdb->prefix ."frm_items where form_id='112' and field_id of form B=". $field_id of form A)

 

Just dont know to put it into code :(

Yes!  I'm looking for the solution to this as well!  However, I do have user information, and it works fine when there is one entry per user.  However, when there are more than one entry, this code updates all entries for the user!  Not ideal.  I'm trying to figure out how to isolate the update based on the entry id instead...and don't know exactly how to code this...

Discussion closed.