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

edited June 25, 2020 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    Is the field in the model from the original row?
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    So only some values are making it into the new row?

    Is the formula field visible to you? ie. field level security
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    er ... uh .... lost me. Screenshots or video would help.
  • edited November 26, 2014
    Working on it! Cheers Pat.
  • edited November 26, 2014
    Here we go...!image
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    Those fields in the drawer. What model/row do they belong to? Do they get saved?
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    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}}
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    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
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    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...}}Β 
  • edited November 26, 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!
  • edited November 26, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited September 1, 2016
    I second that motion. Β We should buy Pat beer.Β 
  • Pat VachonPat Vachon πŸ’ŽπŸ’ŽπŸ’Ž
    edited June 25, 2020
    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"
  • edited June 18, 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 πŸ’ŽπŸ’ŽπŸ’Ž
    edited September 1, 2016
    Thanks for the clarification Peter. Β You are correct.Β 
    (Nice to see you in these parts again. We've missed you)
  • edited August 18, 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.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!