'Create new row" multiple times using the original row's data (row being cloned)

  • 1
  • Question
  • Updated 2 years ago
  • Answered
  • (Edited)
Hi,

In a table I have set up a mass action to kind of 'clone' a row.

Often I would need this action to create multiple new rows using data from the row i selected mass action on (let's call it original row). the first row created works flawlessly, but all the rows after that, do not get info from original row, they try to fetch it from new row created above.

Here's my sequence action and the problem is that the first row gets info from original row perfectly.

Create new row
Add default value {{one_months_ago__c}}
Create new row
Add default value {{two_months_ago__c}}
Save changes in model



I tried specifying the row for merge value {{$Model.Bank_Statement.data.0.two_months_ago__c}} , but still not working.

If i put a save action in between each 'create new row' It kind of works but takes the info from newly created row instead of original, and it's very slow , specially if need to create 12 new rows, could take 5 min+...

Any idea how i could force the default values to be always from the original row, on all the new rows?

Thx


Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Dave, 

Does this need to be in a mass action or would a row action work? If you are only cloning one row it sounds like a row action might be better suited for you, and you wouldn't have the issue of "losing" the row you want to clone. 

Thanks!
Amy
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Hi Amy, Actually I tried with row action , and had same issue, as Matt explained below i guess it's because: Anytime you use the create new row action, the context for the action framework is reset to the row you just created.

But thank you for your help
Photo of Amy Dewaal

Amy Dewaal, Official Rep

  • 8,200 Points 5k badge 2x thumb
Oops, yep, I didn't realize it would grab context even from row action. Sounds like Matt gave you a great option, though!
Photo of Matt Sones

Matt Sones, Champion

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

Anytime you use the create new row action, the context for the action framework is reset to the row you just created. The most reliable way around that which I've seen proffered on the community (I believe Pat got me into this method), is to set up a new model specifically to contain the row you're interested in reusing. have an Id = '' condition on it. Then your row action can set the value for that condition, query that model, and then reference that model with global merge syntax in all your new row creation steps. Does that make sense?
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Thank you Matt, I understand logic and will try it out shortly

Thank you for the help :)