save child records with a parent, for different recordTypes

  • 1
  • Question
  • Updated 3 years ago
  • Answered
  • (Edited)
I have two objects Parent is "Request" and the "FeedBack" Is the child, 
Child has 3 record types and want to save child records for different recordTypes

In Skuid I have three different models for each recordtype

I want to create 3 child records for each recordtype while saving the parent record.

Tried parent model's action to save the child objects with updating values of the fields recordTypeId and parentRecordI didn't work.

Note :  all the child models are there just to create empty rows and not used in Field Editors,
Javascripts etc..




Can someone help me with this please, Thanks in advance
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hasantha,

If you're only using the child models to create new rows, you should be able to set a condition in each of them for the correct record type, along with a 'field from another model' condition tying them to their parent model (Request).

Then you're on-save action on the Requests model should have three "create new row" actions, one for each model, (and then if you also want to save the new rows you created, a single save models action to save all three).

Does that make sense?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
If you want to spin through all records and only create the FeedbackBCC record for partiuclar record types - then I think your custom Javascript is going to be the answer. 

However - if you want the user to have the ability to create the FeedbackBCC record only on particular items - you could control the appearance of that button via conditional rendering.  Then you could use the action sequence to create the new FeedbackBCC record. 
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Rob, Thanks for the reply. now this functionality works fine for Admin user, 
I have another problem, I created a custom profile and assigned the "Request" (Master)object Read,Create,Edit,Delete permissions (removed the modify All Data) and creation of child record stopped working with new profile.

NOTE:
  1. To get the recordtype ids I have three efferent models aligned with particular recordtypes.
  2.  Profile is API Enabled and View Setup and Configuration enabled.
  3. If I create a child record with standard SF it works fine.

Could you help me to figure-out the cause here, what am I doing wrong?

Thanks again
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Question for you.  What record types does the new profile have access to in the Request object?  Unless yo uspecify otherwize I think they'll just have the default record type and then you'll have all sorts of problems. 
Photo of Hasantha Liyanage

Hasantha Liyanage

  • 1,446 Points 1k badge 2x thumb
Rob, The problem here was with the sharing, Once the master record is created, I assign the ownership of the record to another user, I think since the current user does not have access to the master record anymore, it doesn't create the child records.

I tested this with assigning the ownership to the same user while creating the master record, and it works fine.

My solution here was, I generated the detail records with an apex trigger and my problem solved.

Thanks for the support, it helped a lot :)
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Glad you figured it out.  There is great power in the Salesforce security model,  but it also often causes these sorts of unexplained behaviors.