Merging a formula value in a new row created using a row action

Louis SkeltonLouis Skelton Member
edited June 25 in Questions
Morning Folks!

I'm using a row action on a table to create a new row whilst populating its fields with data from the original row. This is working fine except for using a formula field on the original row to populate a field on the new row.

I've tried re-querying the model before updating but that hasn't fixed it - the field comes up blank.

Any ideas?

Cheers!

Louis

Comments

  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    Is the field in the model from the original row?
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Yes, just double-checked. At first I thought that Skuid was processing the row creation before Salesforce had a chance to evaluate the formula field, but even if the formula field's determining values aren't changed as part of the save the value still isn't populated.
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    So only some values are making it into the new row?

    Is the formula field visible to you? ie. field level security
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    All values are making it except for this formula field. And yes, I've got field level access.

    What I'm trying to do is take the original row, click a row action which drops down a drawer which allows you to enter a number. Click a button on the drawer which then saves that row and creates two new rows: one which has a 'Quantity' field populated using the number entered in the drawer, another which has the same 'Quantity' field populated using a formula which references the number entered in the drawer.

    It's this second row that's not populating.
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    er ... uh .... lost me. Screenshots or video would help.
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Working on it! Cheers Pat.
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Here we go...!image
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    Those fields in the drawer. What model/row do they belong to? Do they get saved?
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Yeah, the fields in the drawer belong to the same model as the rows being created. The drawer fields should get saved with the first 'Save Model' action which proceeds the row creation actions. I've tried requerying the model inbetween the save and the new rows but that didn't help.
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    Same model and row? I ask because the moment you make a new row in that model the context merge fields change to that row. So, prior to making rows, save the row and pull that original row into its own model and create the 2 new rows from it. Ie. {{$Model.modelname.data.0.fieldnames}}
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Cheers Pat, I'll give that a try. I get how to use {{$Model.modelname.data.0.fieldnames}} once I've got the row in the model, but how do I allocate the saved row into its own model?
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    Model
    Set max records to 1.
    Create condition of Id = "" Filderable Default Off
    Add fields as necessary.

    Actions to add before creating two new records.
    image
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    I've changed it so that I'm saving the original row into a new model and referencing that row in creating the two new rows but it's still populating all fields except the field that originates from the Formula field. I might try changing the formula into a workflow - see if that works any better.
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    No. No. The formula works. Something else  is going on.
    Display that new model and row on the page to ensure that you can indeed see the data. Make sure to use nothing but {{$Model.modelname.etc...}} 
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    Yeehaa! My mistake - it does work, I'd forgotten to add the formula field to the model that the original row gets inserted into as part of the chain of actions. *Looks sheepish*...

    Thanks for your patience Pat - you're a stalwart and a trooper. If I could, I'd buy you beer.

    Cheers!
  • Louis SkeltonLouis Skelton Member
    edited November 2014
    For anyone else that tries to do things the wrong way - as I was - this here and Pat's next post is the fix.
  • Rob HatchRob Hatch Skuad ✭✭
    edited September 2016
    I second that motion.  We should buy Pat beer. 
  • Pat VachonPat Vachon Member ✭✭
    edited June 25
    You said "We should buy Pat beer"
    You didn't say "We should buy Pat a beer"
    Really should say "We should buy Pat a lifetime supply of Stronbow Cider"
  • PeterPeter Member
    edited June 2019
    Just to be clear for others that had this same issue, as this can be confusing:

    To use a row action to create a new row/record and default/populate a field with data from the original/parent row/record, the original/parent model needs to contain the field that you are referencing. In other words, the new/child model does NOT need to contain parent__r.source_field__c, but the parent model DOES need to contain source_field__c. The new/child model does need to contain the target field into which the default data is being populated, of course.
  • Rob HatchRob Hatch Skuad ✭✭
    edited September 2016
    Thanks for the clarification Peter.  You are correct. 
    (Nice to see you in these parts again. We've missed you)
  • ddeveauxddeveaux Member
    edited August 2015
    Wow so glad I found this. Been pulling my hair out for a bit wondering why I couldn't populate 2nd field on my action. Not sure I would have ended up here!
Sign In or Register to comment.