Using .merge() and trying to get back fields that were update/created


#1

I am trying to do a merge and gett back the fields back that were created/updated/passed in:
targetGroup = MarketingTargetGroup.merge({name: 'testName', marketingOrg: {id: 'fakeOrg'}}, {include: 'name, marketingOrg.id'})

Merge works, however, only the name field is returned to me when the merge returns… I looked over the code and this seems to be the way it should be done. I even looked at the doc and tried that way:
targetGroup = MarketingTargetGroup.make({name: 'testName', description: 'descr', marketingOrg: {id: 'fakeOrg'}}, {include: 'name, marketingOrg.id'}).merge({include: 'name, marketingOrg, description'})

Still does not return me marketingOrg field. Looking at documentation, it doesn’t look like merge can take two arguments. Is there a way to get the object back with the fields specified?


#2

@hehom Unfortunately you can’t. Note that the MergeSpec.include field overrides the base functionality in UpsertSpec.include to indicate the fields that are being merged instead of the base behavior for create/upsert/update where it indicates the fields being returned. You will have to fetch the fields you want afterwards. This is more of an inconvenience than a performance issue since we internally do the refetch anyway for the base behavior.


#3

@trothwein Thanks for the response!