Need to create a record in a model when a record is created in another model

  • 1
  • Question
  • Updated 4 years ago
  • Answered
If there are 2 models 1 is contactmodel and custommodel. If i create a record in contactmodel by entering a last name and first name then a record must be created in another model i.e.. custommodel with name(lastname-firstname) .

How can i achieve the functionality . Thanks in advance
Photo of Robin

Robin

  • 270 Points 250 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Robin

Robin

  • 270 Points 250 badge 2x thumb
Please some one guide me to complete the functionality
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
You have to be more specific about what you want to do here:
What is the relationship between contactmodel and custommodel? Explain how you want these rows created, "a record must be created in another model" what does that mean, what's triggering the record creation? Will the user click a button? If so, it can probably be done via Javascript, but please be as descriptive as possible with your questions (a few screenshots would also help). As far as a resource for this, check out this tutorial, if you have specific questions I can try to answer them.

http://help.skuidify.com/m/components/l/109496-mass-create-records
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
This is a pretty straight forward recipie for the action framework.  In the example I'm going to lay out below I'll add a task automatically when a contact is saved. 

Step 1:  Set up basic Contact and Task Model.   Choose your fields in each one.  There don't really need to be conditions or special model properties applied, but you may want to turn off "load model data" in the advanced tab of the model properties of your task model so that the Task display is blank until you save a contact. 

Step 2:  Build up a basic page.   I used two tables in a panel set showing the data for each model.  Nothing fancy at all. 

Step 3:  Here is the secret sauce.  On the ContactModel add an action to the model. 
- The Initiating Event should be "Model saved" 


- Add several actions: 
Action 1 should be "Create new row in Model" and select the Task Model
Action 2 should be "Update field on row"  Here choose the field in your Task Model and use our global merge syntax to retrieve fields from your Contact model.  (see this document for more about our Global Merge Syntax)
  The syntax is "{{$Model.ModelName.data.0.FieldName}}   Where you replace ModelName and FieldName with the specific values you are interested in.  In my case I prepopulate the word "Contact" and then add the first name and last name fields to the subject of the task. 



Note.  If there is a 1 to 1 match between the contact field and the task field you can use conditions to populate values in the task rather than the actions.  These conditions on the Task Model should be set up as "field from another model" type to bring in data from the contact model. 

If you want to play around with this example - I've posted the XML for this page here. 

I hope this works for you.